ChatGPT解决这个技术问题 Extra ChatGPT

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.

did u find any solution?
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)
I was also getting all sorts of errors, fixed them all by just updating the GitHub extension in Tools > Extensions & Updates.

P
Peter Mortensen

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

https://i.stack.imgur.com/DHn0n.png


This worked for me. Seemed like the easiest of all the suggested solutions too
Glad it helps. Could you please vote it if it helps? It may help others. Thanks!
Thanks for this. Solved my GIt issue in latest updated VS2017
I just removed the git links under generic credentials, it worked.
To get to Credential Manager just search for it in windows 10 (use the windows key). Then click Windows Credentials. Scroll down to the Generic Credential section and look for git: https://your.tfs.server. I received this error after changing my windows password.
P
Peter Mortensen

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


I already had git for windows installed. Executing step 1 and step 5 did it for me.
Ahem - or Enterprise instead of Community in the above path ;-)
@Douglas you're absolutely right. I followed what you mentioned. It fixes the problem.
On Step 4 I used 64-bit Git for Windows and this worked for me. My VS2017 15.7.3 can once again push to my remote without getting this error.
For me, all I needed was step 1. (VS 2017 Enterprise, already had git for windows installed.) I exited Visual Studio 2017 first, deleted that GIT folder, then reloaded VS 2017 and all was well. Removed git folder from C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer
P
Peter Mortensen

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


This worked for me, but where the heck did you find the clue?
Same trick works for 'Professional', copy the dll's, close VS instances, reopen one and try to close again.
Those were not the only files that were missing for me. This link describes how to find out what you have to copy. developercommunity.visualstudio.com/content/problem/27220/…
This may well be the solution we're all looking for! Thank you!
@StingyJack I reported the issue to Microsoft together with a Procmon dump, and the supporter from Microsoft identified that it used the wrong dll. I never did find out exactly which application I had installed that had put its required version of libeay32.dll/ssleay32.dll in the system32 folder either..
A
Abdellah Azizi

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

and Retry..

Enjoy !


Why do you think that the issue in wrong creds? It will help only in one case but you'll receive another error. Thi doesn't solve problem
I have no idea why my old credentials stop working (I did not change any credentials), Thanks for saving my day.
P
Peter Mortensen

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

Modify Visual Studio 2017 CE installation → remove Git for windows (installer → modify → single components). Delete everything from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git. Modify Visual Studio 2017 CE installation → add Git for windows (installer → modify → single components) 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.


Worked for me, but just after 1 I also uninstalled Git for Windows in the program list for my PC.
This worked for me. So it looks like the version of Git that MS ships is bad, and replacing it with the official Git for Windows release fixes the problem - just make sure it's in the PATH, and the only version of git that is installed. I think we're finally migrating to VS2017.
P
Peter Mortensen

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.


P
Peter Mortensen

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.


Mine was similar to this. I was having an issue where the newer version of VS 2017 (15.3.2) was all of a sudden constantly making me check in this odd storage.ide file. I had to keep committing that file after closing/opening VS and that finally worked. Disclaimer - I also completed the steps in the most accepted answer above as well.
I just noticed that all files I committed, was still under "Changes". I recommitted them. And problem's gone away.
G
GGleGrand

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.


P
Peter Mortensen

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

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


I have two machines. Both have VS2017RTM on them. Same version of VS and same version of GitHub.VisualStudio. Neither TeamExplorer folder has a Git folder in it. One works and one doesn't. :(
Unbelievable - I deleted the git folder here, but it worked! C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git
É
Éric Bergeron

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


P
Peter Mortensen

I'm using GitKraken and Visual Studio 2017.

When GitKraken clones a repository, it leaves fetch address like "git@github.com: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 "/".


W
Wagner Melo

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

R
Rex Andrew

https://i.stack.imgur.com/QyVoU.png

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"

https://i.stack.imgur.com/cR7Oy.png

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


J
Jess

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:

https://i.stack.imgur.com/zIup0.png

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.


This seems to be the smartest solution! Thank you ;)
C
Casey

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


J
Jerry

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.


VS is incapable of making a new remote origin. This is the only thing that works for me. You do the initial push to the remote on the command line or with Tortoise and then VS can use it.
P
Peter Mortensen

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.


P
Peter Mortensen

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.


This was my problem too. I had to uncheck the Block command line pushes that expose my email setting, push commits that were pending. Then I configured my GitHub no-reply email address in git global config. Any future commits were then associated with that email and can now be pushed even with the Block command line pushes that expose my email turned on again.
P
Peter Mortensen

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


m
maxim1500

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


J
John Dow

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


X
XYZ

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):

In Visual Studio, double click on your "rogue" remote branch; VS should have now created a local branch from it; Right click on the local branch, select "Unset remote branch"; Right click on the local branch, select "Push branch"; You should now have a true corresponding remote branch; 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.


M
MAQ

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.


C
Community

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.


P
Peter Mortensen

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
user.email=xxxxx@xxxxxx.xx
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://xxxxxx@bitbucket.org/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.


P
Peter Mortensen

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.


C
Community

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.


Thank you this solved my issue. I changed my domain username password and before I did, i had uncommitted changes. When used git pull, it shows change username password popup which helped me understand what was the problem. Then I did git reset to lose all the previous change and then it solved my problem in Visual studio
P
Peter Mortensen

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.


C
CodesOfPSJ

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


L
Luiz Fernando Corrêa Leite

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 worked for me. Seemed like the easiest of all the suggested solutions too.