简体   繁体   English

Visual Studio 2022 源代码管理未显示更改

[英]Visual Studio 2022 source control not showing changes

Visual Studio 2022 not showing any change of file in git changes window, although there are some files updates are available. Visual Studio 2022 未显示 git 更改 window 中的文件的任何更改,尽管有一些文件更新可用。 Whereas GIT GUI is showing all the changes in the repository.而 GIT GUI 显示存储库中的所有更改。

Once I open the repository in GIT GUI all changes are also begin to display in Visual Studio git changes window.一旦我在 GIT GUI 中打开存储库,所有更改也开始在 Visual Studio 中显示 git 更改 window。

visual studio 2022 shows "error parsing the git status output.". Visual Studio 2022 显示“解析 git 状态 output 时出错。”。 It is maybe because of mismatched versions of git or visual studio.这可能是因为 git 或 Visual Studio 的版本不匹配。

as a workaround, in "Package Manager Console" you can run this command:作为一种解决方法,您可以在“包管理器控制台”中运行以下命令:

git status

after that, visual studio shows your changes, and you can commit them!之后,visual studio 会显示您的更改,您可以提交它们!

I ran into the same issue.我遇到了同样的问题。 Then I found the answer under this video .然后我在这个视频下找到了答案。 Try this:尝试这个:

git config --global --add safe.directory C:/Path/To/Repo

Notice the forward slashes.注意正斜杠。

It might be an issue with the git index lock.这可能是 git 索引锁的问题。 This solved my problem, deleting the index lock file: Visual Studio: Git Team Explorer does not show any changes这解决了我的问题,删除索引锁定文件: Visual Studio: Git Team Explorer does not show any changes

I used to connect not as admin .我以前不是as admin身份连接的。 Then in Git Repository Settings no remotes were displayed and at Git Changes there were only "create new" options.然后在 Git Repository Settings 中没有显示遥控器,并且在 Git Changes 中只有“创建新”选项。

Then I connected as admin and remotes become available, all were working as usual.然后我as admin连接并且遥控器变得可用,一切都照常工作。 Makes no sense to me but it's "working".对我来说没有意义,但它正在“工作”。

TL'DR TL'DR

Make sure both git and vs are up-to-date + use git status and if you got a fatal: detected dubious ownership error, then run git config --global --add safe.directory '*' and restart VS, finally, if none of these works and your local and remote copies are synced: delete the local copy and re-clone the repo again!确保 git 和 vs 都是最新的 + 使用git status ,如果你得到一个致命的:检测到可疑的所有权错误,然后运行git config --global --add safe.directory '*' ,最后安全如果这些都不起作用并且您的本地和远程副本已同步:删除本地副本并再次重新克隆存储库!


Possible Causes:可能的原因:

  1. Git, VS Versions' mismatch: I have VS2022 up-to-date, but git-bash -> git --version was 7-versions old, so I have used git-bash -> git update-git-for-windows command to have an up-to-date version of git (you can download the 'git.exe' installer as an alternative). Git, VS Versions' mismatch: I have VS2022 up-to-date, but git-bash -> git --version was 7-versions old, so I have used git-bash -> git update-git-for-windows command拥有最新版本的 git(您可以下载“git.exe”安装程序作为替代)。 This shows git information in vs statusbar, but some solutions still not showing the git information, if this not works for you.这会在 vs 状态栏中显示 git 信息,但如果这对您不起作用,某些解决方案仍然没有显示 git 信息。 try the next step..尝试下一步..

  2. In Visual Studio: View -> Other windows -> Package Manager Console, then type git status .在 Visual Studio 中:查看 -> 其他 windows -> Package 管理器控制台,然后键入git status In my case, it gives me a security fatal error!就我而言,它给了我一个安全致命错误!

     git: fatal: detected dubious ownership in repository at 'path-to-solution' At line:1 char:1 + git status. .

    To overcome this, I have used the following command to get rid of this issue forever: git config --global --add safe.directory '*'为了克服这个问题,我使用了以下命令来永远摆脱这个问题: git config --global --add safe.directory '*'

  3. If the project is relatively old, try re-cloning it again (if local and remote are synced, if not: delete the.git folder, clone the repo to a new folder, copy the.git folder from there and paste it in root folder, add and commit your changes).如果项目比较老,请尝试重新克隆它(如果本地和远程同步,如果没有:删除.git文件夹,将repo克隆到新文件夹,从那里复制.git文件夹并将其粘贴到root文件夹,添加并提交您的更改)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM