Visual Studio 2017 - Git failed with a fatal error
I am using Visual Studio 2017 Community Edition (CE), and I have signed into my Microsoft account and I am connected to VSTS. I can see all my projects and repositories, but when I attempt to pull/fetch/push any changes I get the following error:
Error encountered while pushing to the remote repository: Git failed with a fatal error.
PushCommand.ExecutePushCommand
And accordingly for the fetch and pull commands too.
I installed Git for Windows on the Visual Studio 2017 installer and not only is it failing to work with VSTS, I am unable to work with any of my GitHub repositories too. Has anyone else noticed this? It's happened on two of my machines so far.
Visual Studio 2015 Enterprise Edition (EE) and CE work completely fine for me.
It seems that this issue has gotten far more recognition that I thought it would which leads me to believe that this is an issue with how Visual Studio is dealing with Git. I have also noticed that every time I update Visual Studio, this problem pops back up, and I have to go through the steps in some of the answers below to get Git working again. I'm not sure why this is happening, and I also don't know if Microsoft are planning to resolving this issue.
Solution 1:
After I changed the generic credentials from Control Panel → User Accounts → Credential Manager for Git, it worked for me.
Solution 2:
I'm going to add a solution here that the previous answers have not already mentioned, but this is what fixed it for me.
Navigate to
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\
and delete theGit
folder.Make sure that there is no version of Git installed on your system, remove it by going to Control Panel → Program and Features (TortoiseGit does not need to be removed from my experience, just native git installations).
Open up the Visual Studio 2017 installer and untick "Git For Windows" in installation options.
Head over to the Git website and install the latest version of Git for Windows.
Go back into the Visual Studio installer and tick "Git for Windows" again. It will not download a new version even though it may look like it is. After that is done, your Git should be fine with VSTS and TF Explorer.