173
votes

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.

30
did u find any solution?GorvGoyl
try going to the solution folder in cmd and using git push to see the actual error, I had the same issue, tried many thing, the command line gave me the actual reason for the failure (I marked my email as private in github and it was conflicting with the push details as it would make my email visible in the code change)Royi Mindel
I was also getting all sorts of errors, fixed them all by just updating the GitHub extension in Tools > Extensions & Updates.Daniel Bailey

30 Answers

123
votes

After I changed the generic credentials from Control PanelUser AccountsCredential Manager for Git, it worked for me.

Enter image description here

78
votes

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

42
votes

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

19
votes

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

and Retry..

Enjoy !

16
votes

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.

11
votes

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.

7
votes

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.

5
votes

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.

4
votes

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

4
votes

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 ExplorerSettingsRepository SettingsRemotesEdit, and change "git@" to "https://" and ":" to "/".

4
votes

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
4
votes

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

3
votes

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
3
votes

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.

2
votes

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
1
votes

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.

1
votes

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.

1
votes

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.

1
votes

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

Team ExplorerSettingsRepository SettingsRemotesEdit

1
votes

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

1
votes

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.

1
votes

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.

0
votes

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.

0
votes

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.

0
votes

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.

0
votes

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.

0
votes

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.

0
votes

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

0
votes

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

0
votes

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