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

验证:

相关推荐
゛凌乱的记忆づ17 小时前
好用的md文件编辑器——TyporaS与Typora
笔记·git·typora·markdown
এ慕ོ冬℘゜20 小时前
Git 基础规范:小步提交、提交信息规范与常用命令
git·svn
忘了ʷºᵇₐ21 小时前
Git学习笔记
笔记·git·学习
BIBI20492 天前
换 Git 托管平台怎么做?基于 TortoiseGit 的跨平台迁移教程
windows·git·tortoisegit·问题解决·版本控制·最佳实践
echome8882 天前
Git 日常救急:撤销提交、找回误删文件和解决冲突
git·版本控制
赵民勇2 天前
Git命令详解
git
不老刘3 天前
Antigravity 的 New Worktree 模式:给 AI 代理一个安全的“平行工位”
人工智能·git·ai编程·antigravity
光谱SpectrAI3 天前
Windows 也中招:Git Bash 和 Node 仍信任泄露的 eMudhra 证书
git
YIN_尹3 天前
【git原理与使用】git初识与安装
大数据·git·elasticsearch
Leo_Mr3 天前
Vue3 项目配置 Git 提交规范(企业通用方案:husky + commitlint + cz-git + lint-staged)
git