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

验证:

相关推荐
像风一样的男人@14 小时前
warning: could not find UI helper ‘git-credential-manager-ui‘
git·ui
代钦塔拉15 小时前
Git & GitHub 从入门到精通:全流程实战教程
git·github
晚风吹红霞17 小时前
Linux下的趣味编程 —— 进度条、Git版本控制与GDB调试实战
linux·运维·git
xlq2232217 小时前
7.git
git
Ws_17 小时前
Git + Gerrit 第六课:commit --amend、Patch Set 与 Change-Id
git
AIMath~1 天前
向github中上传文件过大超过50M怎么办
网络·git·github
AIMath~2 天前
如何将一个新的文件夹使用git 工具提交到github新仓库中
git·github
满天星83035772 天前
【Git】原理及使用(二) (版本回退)
linux·git
愿天垂怜2 天前
【C++脚手架】ffmpeg 库的介绍与使用
linux·服务器·开发语言·c++·ide·git·ffmpeg
月夜的风吹雨2 天前
Linux 基础开发工具详解:从 yum 到 gdb 实战指南
linux·git·ubuntu·centos·vim