VS 版本更新git安全保护问题的解决

问题:

我可能移动了一个VS C# 项目,然后,发现里面的git版本检测不能用了

正在打开存储库:

X:\Prj_C#\3D

fatal: detected dubious ownership in repository at 'X:/Prj_C#/3DSnapCatch'

'X:/Prj_C#/3D' is owned by:

'S-1-5-32-544'

but the current user is:

'S-1-5-21-900372847-2521881049-1049374117-1001'

To add an exception for this directory, call:

git config --global --add safe.directory 'X:/Prj_C#/3DSnapCatch'

一个做了很久的项目,然后,COPY来,COPY去,后来,客户发了问题要修改,看git版本,VS 里面的git给出了安全的提示。就是不同的用户,你不能访问了。估计是VS登陆的时候,用了不同的用户名,也没注意,总之,VS里面又包了一层。

奇怪的是如果用本地的,git shell,却是可以的:

所以,这个安全目录,感觉就是VS搞的一个附加的安全措施。


解决办法:

1确认安全目录:

确定项目目录下,所有的安全git工作目录:

复制代码
git config --global --get-all safe.directory

比如我的:

复制代码
X:\Prj_C#\3DSnapCatch>git config --global --get-all safe.directory
X:/Prj_C#/3DSnapCatch

如果有多个重复的,那么就不行,会有问题。比如:

复制代码
X:\Prj_C#\3DSnapCatch>git config --global --get-all safe.directory
X:\Prj_C#\3DSnapCatch
X:\Prj_C#\3DSnapCatch

2 移除所有安全目录

如果有重复的,我们需要运行下面的代码:移除所有的安全目录:

复制代码
X:\Prj_C#\3DSnapCatch>git config --global --unset-all safe.directory

【最好的方法,可以上来先移除所有的安全目录,重做一边】

3 重新构建安全目录:

复制代码
X:\Prj_C#\3DSnapCatch>git config --global --add safe.directory "X:/Prj_C#/3DSnapCatch"

4 确认一下:

复制代码
X:\Prj_C#\3DSnapCatch>git config --global --get-all safe.directory
X:/Prj_C#/3DSnapCatch

验证:

相关推荐
好好沉淀7 分钟前
ide进去git突然报Cannot identify version of git executable: no response的错误
git
宇宙超级无敌霸王龙捏4 小时前
Git 分支完整操作指南
git
学编程的小鬼7 小时前
git 中常用的命令
git
小黄酥8 小时前
Sourcetree克隆/获取gitee工程,Git获取SSH密钥
git·gitee·github
小Lu的开源日常9 小时前
踩坑日记:为什么 .gitignore 不起作用了
git·代码规范·trae
Gazer_S13 小时前
【Git 子模块冲突解析】
git
她说..13 小时前
通过git拉取前端项目
java·前端·git·vscode·拉取代码
freedom_1024_13 小时前
解决GitHub大文件推送错误:彻底清理PDB文件并配置.gitignore
git·github
未来的JAVA高级开发工程师13 小时前
Git--
git
sitellla16 小时前
Testify Go测试工具包入门教程
git·测试工具·其他·golang