[git] 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.

This question is related to git visual-studio azure-devops visual-studio-2017

The answer is


I had a different problem. My computer contained older OpenSSL DLL files in system32 and syswow64 so to fix my problem, I had to copy libeay32.dll and ssleay32.dll from one folder to another folder within the Git folders of Visual Studio 2017.

FROM: C:\Program Files (x86)\Microsoft Visual Studio\2017\vs_edition\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin\

TO: C:\Program Files (x86)\Microsoft Visual Studio\2017\vs_edition\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core

Ref.: Git - Can't clone remote repository


In my case I didn't have to do anything so drastic as uninstalling Git as per some of the answers here; I just had to use the command line instead of Visual Studio.

Open up cmd at your solution's root and enter:

git pull

You will then be told exactly what the issue is. In my case it told me that I had uncommitted changes that would have been overwritten and that I needed to commit them before I could continue.

Once I had done this the pull succeeded, and I could resolve the conflict in the merge tool.

TLDR

Use the command line instead of Visual Studio to get a more complete error message.


I was getting similar issues. In Visual Studio 2017, with Rebase option I solved my issue.

I am having only a master branch. I rebase from master to origin/master (means to the same branch) and clicked Rebase. Before doing Rebase, the status was, I was committed my changes however not able to push/sync as my local branch base and Git code base was not synchronised state.


The below fixes my problem.

  1. Navigate to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\ and delete the Git 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).

  2. Open up the Visual Studio 2017 installer and untick "Git For Windows" in installation options.

  3. Head over to the Git website and install the latest version of Git for Windows.

  4. 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 installation should be fine with VSTS and TF Explorer.


I also had this issue after I got wget from the GNU tools, and copied it right into c:\windows. The libeay.dll and libssl.dll files were also in the archive. When those were in c:\windows, I had this issue. Removing them immediately fixed it. So, check if you have these .DLLs somewhere in your path, VS may be picking up some other software's version of these instead of using the ones it expects.


In my case, Windows had ran an update and was waiting to restart the PC. I hadn't seen any notifications but, well... turning it off and turning it on again fixed the problem.

Try that first before monkeying with any of these Visual Studio directories and applications.


I got it working by removing username@ from http://username@asdf/xxx/yy/zzz.git in the repository settings:

Team Explorer ? Settings ? Repository Settings ? Remotes ? Edit


I was able to fix the issue using this line in the command line without reinstalling anything.

git config --global credential.{myserver}.authority NTLM

Simply replace {myserver} with the hostname of your server (without http or port number).

After that, VS was able to connect correctly.

Source: https://github.com/Microsoft/Git-Credential-Manager-for-Windows/blob/master/Docs/Faq.md#q-i-thought-microsoft-was-maintaining-this-why-does-the-gcm-not-work-as-expected-with-tfs


enter image description here

When i do pull/fetch/push i got the above error in my output window, i followed the below soloution , it resovled my issue.

If you are using visual studio 2017 enterprise edition, replace the userId with your user id in the below command and execute this command in windows run window(windows key + R).

runas /netonly /user:UserId "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe"

enter image description here

This will prompt for password, enter your password. A new visual studio instance will open and will start working properly...


I'm using GitKraken and Visual Studio 2017.

When GitKraken clones a repository, it leaves fetch address like "[email protected]:user/Repo.git", instead of "https://github.com/user/Repo.git".

To fix that, go to Team Explorer ? Settings ? Repository Settings ? Remotes ? Edit, and change "git@" to "https://" and ":" to "/".


I had this problem after changing the git access password!

I had to reset the credentials through the PowerShell console.

At the git repository folder level, the script was as follows:

git config --system --unset credential.helper

git config --system credential.helper store

git fetch

You will be prompted for the user and then the password.

The next command will no longer request authentication:

git fetch

I got the following error messages using Visual Studio 2017 CE.

Failed to push to the remote repository. See the Output window for more details.

The output window showed the following:

Error encountered while pushing to the remote repository: Git process failed unexpectedly. PushCommand.ExecutePushCommand

I tried to push changes using GitHub Desktop. It shows the following error message.

Cannot push these commits as they contain an email address marked as private on GitHub.

That's It. Solution:

open GitHub account >> Settings >> Emails >> Uncheck "Keep my email address private"

It's done. That was the problem in my case.


AngelBlueSky's answer worked partially for me. I had to execute these additional lines to clean the Git global configuration after step 4:

git config --global credential.helper wincred
git config http.sslcainfo "C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt"
git config --global --unset core.askpass
git config --global --unset mergetool.vsdiffmerge.keepbackup
git config --global --unset mergetool.vsdiffmerge.trustexitcode
git config --global --unset mergetool.vsdiffmerge.cmd
git config --global --unset mergetool.prompt
git config --global --unset merge.tool
git config --global --unset difftool.vsdiffmerge.keepbackup
git config --global --unset difftool.vsdiffmerge.cmd
git config --global --unset difftool.prompt
git config --global --unset diff.tool

Then git config -l (executed from any git repo) should return only this:

core.symlinks=false
core.autocrlf=false
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
diff.astextplain.textconv=astextplain
rebase.autosquash=true
user.name=xxxxxxxxxxxx
[email protected]
credential.helper=wincred
core.bare=false
core.filemode=false
core.symlinks=false
core.ignorecase=true
core.logallrefupdates=true
core.repositoryformatversion=0
remote.origin.url=https://[email protected]/xxx/xxx.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.identityserver.remote=origin
branch.identityserver.merge=refs/heads/identityserver
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt

Run the git status and git fetch commands to validate that it works from the command line.

Then go to Visual Studio, where your repositories should be back, and all sync/push/pull should work without issues.


I tried a lot and finally got it working with some modification from what I read in Git - Can't clone remote repository:

  1. Modify Visual Studio 2017 CE installation ? remove Git for windows (installer ? modify ? single components).

  2. Delete everything from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git.

  3. Modify Visual Studio 2017 CE installation ? add Git for windows (installer ? modify ? single components)

  4. Install Git on windows (32 or 64 bit version), having Git in system path configured.

Maybe point 2 and 3 are not needed; I didn't try.

Now it works OK on my Gogs.


If you are using a proxy, open a command prompt and try:

git config --global http.proxy <proxy address>:<port>

More info at: https://github.com/desktop/desktop/issues/2789


Compounded the problem by deleting the local repo so I could clone a fresh copy. I was faced with new error "git cannot be found Git failed with a fatal error.fatal: repository 'xyz' not found"

I tried everything suggestions i google about with no resolution. The following simple step worked for me and I am adding it to the growing list of possible resolutions:

git config --get http.proxy result is http://google.com:80

this is not right so i got rid of it.

git config --global --unset http.proxy


I had a very similar problem and the instructions from a tech at Microsoft fixed it for me:

  • Close all instances of Visual Studio.
  • Open the Task Manager and check if any TFS Services are running. Select each of them and click on End Process Tree.
  • Browse to the folder below and delete all the contents and folders in %LocalAppData%\Microsoft\Team Foundation{version}\Cache
  • Go to Control Panel -> User Accounts -> Manage your Credential -> Windows Credential, select the VSTS URL to remove it
  • Then go to "C:\Users\USER NAME\AppData\Local\GitCredentialManager\tenant.cache" and delete it
  • Also go to "C:\Users\USER NAME\AppData\Local.IdentityService" and delete it

I fixed this problem by uninstalling the 64-bit version and installing a 32-bit version of Git


I had the same error pop up in VS 2017 when trying to delete a remote branch. The issue was that the branch was not on the server (using TFS2018 with GIT), but somehow Visual Studio did have it show up in the "remote/origin" section. This meant that I could not delete the remote branch (VS was giving out this error, while the server explorer didn't show up the branch at all).

Here's how to fix it (tested in VS 2017):

  1. In Visual Studio, double click on your "rogue" remote branch;
  2. VS should have now created a local branch from it;
  3. Right click on the local branch, select "Unset remote branch";
  4. Right click on the local branch, select "Push branch";
  5. You should now have a true corresponding remote branch;
  6. Delete the remote branch, then the local branch.

Hopefully it will help someone who ends up on this thread having the same issue as me.


Understand Why are you getting this error : if you are able to delete your other branches but not another branch, then there is a case that you are not the owner of that branch, ie. the branch has been created by some one else and you are using it.

Easy Solution : you can ask the owner of the branch to delete it !! simple:)

Problem faced: Error encountered while deleting branch from the remote repository: PushCommand.ExecutePushCommand


  1. Navigate to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\
  2. Delete the Git folder
  3. Visual Studio

I once had such an error from Git while I was trying to synchronise a repository (I tried to send my commits while having pending changes from my coworker):

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

It turned out that after pressing the Commit all button to create a local commit, Visual Studio had left one file uncommitted and this elaborated error message actually meant: "Commit all your changes".

That missing file was Entity Framework 6 model, and it is often shown as uncommitted file although you haven't changed a thing in it.

You can do commit all or undo all changes that are not committed.


In Control Panel\All Control Panel Items\Credential Manager ==> Windows Credentials Remove Git:http://........

and Retry..

Enjoy !


I opened Credential Manager in Windows (not Visual Studio), selected "Windows Credentials", found my git:https//stash....com Generic Credential, clicked the bubble arrow down to make visible the User name and Password fields with Edit button. Clicked Edit, and put in my correct password there. Then started work right after that, no need to close anything.


Try:

Closing all instances of VS and then deleting the account for the TFS server in Control Panel -> User Accounts-> Credentail manager

Refer: https://developercommunity.visualstudio.com/content/problem/142173/after-changing-domain-password-couldnt-connect-to.html


This problem allways occures to me - when i have to change my password. It feels like there is allways another problem with my old credentials dont get updated.

  1. Go to your Windows Credential Manager

  2. Remove all Tfs Credential Entries

Finished


I get the following error message when trying to push with the GitHub Extension for Visual Studio:

Error encountered while pushing branch to the remote repository: Git failed with a fatal error repository 'https://github.com/my-repo' not found

I know that the repository exists, I pulled from it. Unfortunately the error message in this situation does not indicate the root cause: I did not have write permissions for that repository


I had the same issue. Restarting Visual studio worked for me... You may try it before reinstalling stuff.


I ran into this issue as well. I had sync'd my code earlier in the day so it made no sense that it suddenly gave this Git error. Restarting Visual Studio did not make any difference. After reviewing the above answers and not finding any clear solution, I decided to try syncing outside of Visual Studio using TortoiseGit which I already had installed. This worked. I was then able to sync within Visual Studio normally. If you don't already have TortoiseGit, you may download it (free) from tortoisegit.org.


I'm going to add a solution here that the previous answers have not already mentioned, but this is what fixed it for me.

  1. Navigate to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\ and delete the Git folder.

  2. 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).

  3. Open up the Visual Studio 2017 installer and untick "Git For Windows" in installation options.

  4. Head over to the Git website and install the latest version of Git for Windows.

  5. 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.


I had the same issue. The following steps solved the problem for me:

  1. Backup and delete "C:\Program Files (x86)\Microsoft Visual Studio 14.0\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git"
  2. Install latest version of Git: https://git-scm.com/download/win

This is the error I was getting:

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

I tried all the previous methods, but they didn't work. Later I found out that there were some conflicts in the code (see the Visual Studio 2017 output window).

I simply reverted the code and it worked.


Wow! There are so many solutions to this problem!

Try this easy one!

Change your password!

Just the other day, I started getting this notice that my password would expire in 14 days. Now 2 days later, I am getting this error:

enter image description here

I really didn't feel like hacking git or OpenSSL libraries, so I just changed the Windows password on my computer and it worked!

Update

Then it started happening again. From Team Explorer go to Sync. Then do Actions > Open Command Prompt. In the command prompt type git push origin. That might work for you.


If it doesn't work from Team ? Manage Connections ? Local Git Repositories ? Clone, one can try either one these two ways.

Menu File ? Start Page ? Open ? Go for Git

(or)

Menu File ? Open ? Open from source control


I tried this: https://stackoverflow.com/a/43257818/1831734

But this not solved my problem. I did following [WINDOWS]

  1. Go to repository browser with CMD
  2. type: git push

Result: ...

...
remote: Resolving deltas: 100% (11/11), completed with 10 local objects.
remote: error: GH007: Your push would publish a private email address.
remote: You can make your email public or disable this protection by visiting:
remote: http://github.com/settings/emails
To https://github.com/userName/repoName
 ! [remote rejected] main -> main (push declined due to email privacy restrictions)
error: failed to push some refs to 'https://github.com/userName/repoName'

I went to: http://github.com/settings/emails and checked settings then changed my email in Visual Studio/local computer

Setting your email address for every repository on your computer

  1. Open Git Bash.

  2. Set an email address in Git. You can use your GitHub-provided no-reply email address or any email address.

    $ git config --global user.email "[email protected]"

  3. Confirm that you have set the email address correctly in Git:

    git config --global user.email [email protected]

    Add the email address to your account on GitHub, so that your commits are attributed to you and appear in your contributions graph. For more information, see "Adding an email address to your GitHub account."

  4. Reset the author information on your last commit:

    git commit --amend --reset-author


One tip for those new git users. U need to commit before revert to old code. I tried every solution under this question then I found this stupid stuff by myself. :)


Many solutions here, for me here's what worked.

  1. I first changed the credentials from my Windows. In your Windows search, search "Credentials Manager", then go to "Windows Credentials", and updated (Edit option) my password to my new password. (Control Panel ? User Accounts ? Credential Manager for Visual Studio Git)

  2. I restarted Visual Studio, and tried to push, but I still got the "Authentication failed error".

  3. I went to back to the Windows Credential manager in step 1 and deleted(Remove option) the GIT account tied to my Visual Studio, I pushed again and it went through.


I got this error while trying clone a new repository. After trying several solutions following worked for me. From browser Go to dev.azure.com and go to your repo click on Clone and in the IDE select Visual Studio and click on Clone. It will open up visual studio and set the credentials. if it again asks for credentials click on Generate git credentials and use it. Works like a charm.

Close Repository


After installing the last version of Git for Windows you must to open the configuration file to edit:

git config --global --edit

Click Insert, remove all the settings, click Esc, type :wq and, Enter to save.

Now you can clone the repository by Bash or IDE with a valid user.


After I changed the generic credentials from Control Panel ? User Accounts ? Credential Manager for Git, it worked for me.

Enter image description here


In my case a failing Jest unit test preventing the push to the repo gives the same generic error of "Error encountered while pushing to the remote repository: Git failed with a fatal error."


This appears to happen in VS 2017 when there is a pending commit that would conflict with the pull. If you go to a command terminal and do a "git pull origin", you will usually get the error that is the source of the confusion. To solve, check in all your changes in VS 2017 and then try the pull or sync again from VS 2017. Needless to say ... this is not desired behavior in VS 2017.


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to visual-studio

VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio? How to download Visual Studio Community Edition 2015 (not 2017) Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio Code pylint: Unable to import 'protorpc' Open the terminal in visual studio? Is Visual Studio Community a 30 day trial? How can I run NUnit tests in Visual Studio 2017? Visual Studio 2017: Display method references

Examples related to azure-devops

Visual Studio 2017 - Git failed with a fatal error Authentication failed for https://xxx.visualstudio.com/DefaultCollection/_git/project Git in Visual Studio - add existing project? Error TF30063: You are not authorized to access ... \DefaultCollection How can I change the default credentials used to connect to Visual Studio Online (TFSPreview) when loading Visual Studio up? Free Online Team Foundation Server

Examples related to visual-studio-2017

Assets file project.assets.json not found. Run a NuGet package restore How to remove an unpushed outgoing commit in Visual Studio? The current .NET SDK does not support targeting .NET Standard 2.0 error in Visual Studio 2017 update 15.3 Create Setup/MSI installer in Visual Studio 2017 VS 2017 Metadata file '.dll could not be found Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error Visual Studio 2017 does not have Business Intelligence Integration Services/Projects How can I run NUnit tests in Visual Studio 2017? How to integrate SAP Crystal Reports in Visual Studio 2017 Unit Tests not discovered in Visual Studio 2017