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

验证:

相关推荐
我是一只代码狗10 小时前
idea中合并git分支
git
我是一只代码狗10 小时前
idea中使用git
git·gitee·github
恋喵大鲤鱼10 小时前
git restore
git·git restore
李少兄11 小时前
Git Commit Message写错后如何修改?已Push的提交如何安全修复?
git·安全
Fireworkitte11 小时前
git stash
git
pe7er1 天前
git submodule简易指南
git
xiaocainiao8811 天前
Python 实战:构建 Git 自动化助手
git·python·自动化
Casia_Dominic2 天前
【三维重建工具】NeRFStudio、3D GaussianSplatting、Colmap安装与使用指南
git·3d·github·点云