Search code examples
gittfsvisual-studio-2017

Git Failed with a Fatal Error in Visual Studio


I have been pulling and pushing my project to TFS from Visual Studio 2017 for a while now. Until recently, I cannot pull from the remote repo

I get this error:

Git failed with a fatal error. pull --verbose --progress --no-edit --no-stat --recurse-submodules=no origin

I have tried different ways to solve this

  1. From Team Explorer/Settings/Repository Settings, I checked override global username and email and manually entered the credentials for that repo --didn't fix it

  2. I reinstalled Git from Visual Studio installer --didn't fix it

Note: This is happening to every project I try to pull or push in my VS (even projects that are not in TFS)

How can I fix this?


Solution

  • Considering the local and remote branching have diverged, you could setup Git to "do the right thing" (which is to rebase your local work on top of the remote branch). See "Can “git pull” automatically stash and pop pending changes?"

    git config --global pull.rebase true
    git config --global rebase.autoStash true
    

    That way, TFS should do a git pull (as you mention) which in this case you fetch origin/working, and rebase working on top of origin/working.
    This is easier than using Visual Studio to do the same rebase.