Having trouble committing to git with Visual Studi

2019-06-07 18:37发布

When I created the project I was able to commit about 2 times, but now it doesn't allow me. The button is grayed out like this:

enter image description here

All I've done was edit the code in my project. I got out of Visual Studio and the next day I came back and it's not working. How do I fix this?

2条回答
狗以群分
2楼-- · 2019-06-07 18:48

When the GUI fails, revert back to the command line.

Unzip the latest git-for-windows release like PortableGit-2.9.0-64-bit.7z.exe anywhere you want (like C:\git\2.9.0), and add it to your path (set PATH=%PATH%;C:\git\2.9.0\bin)

Then do in a CMD:

cd /path/to/your/repo
git status
git branch
# try and modify files
git status
# Check if Visual Studio authorizes you to commit
# if not
git add .
git commit -m "changes"
查看更多
Explosion°爆炸
3楼-- · 2019-06-07 19:02

This sounds like a bug that was fixed in Visual Studio 2015 Update 2: briefly, Visual Studio spawns a background thread to check the status of your repository. If that thread throws an exception for some reason, Visual Studio will never report the status. (And, consequently, will not let you commit your changes.)

Installing the latest Update 3 should fix this problem:
https://www.visualstudio.com/en-us/news/releasenotes/vs2015-update3-vs

(And of course, @VonC has the quite correct workaround that the command line is immune to such issues.)

查看更多
登录 后发表回答