2023-09-24 windows上TortoiseGit 报错 detected dubious ownership 的问题

在一次换了电脑(硬盘clone)之后,我的TortoiseGit在操作git代码时就会有以下提示,使用SystemInformer查看电脑上的账户对应的sid发现。git提示的文件夹现有拥有者是Administrators组,而当前用户是当前正在登录的这个用户。

image.png

网上的方案有两种:
1、按着提示,将代码目录添加到git的安全目录列表中,这样git就不会检测这个目录的所有者了。
2、修改文件夹权限,使用继承权限的方式将所有文件的拥有者改回原拥有者。

但都是很麻烦,需要一个目录一个目录的设置。后来在:Git command returns fatal error: "detected dubious ownership" | Bitbucket Cloud | Atlassian Documentation
中发现以下内容:

if using git > 2.36, there's also a wildcard to add all folders to safe.directory list :

git config --global --add safe.directory '*' # For the current user and all repositories
git config --system --add safe.directory '*' # For all users and all repositories

但实测下来,在windows中是不需要那个单引号的。只需要 git config --global --add safe.directory *即可。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容