可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.
回答1:
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.
回答2:
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
回答3:
After I changed the generic credentials from Control Panel → User Accounts → Credential Manager for Git, it worked for me.
回答4:
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.
回答5:
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.
回答6:
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.
回答7:
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.
回答8:
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 "/".
回答9:
I had the same issue. Restarting Visual studio worked for me... You may try it before reinstalling stuff.
回答10:
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
回答11:
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.
回答12:
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.
回答13:
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.
回答14:
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
回答15:
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.
回答16:
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.
回答17:
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.
回答18:
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.
回答19:
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
回答20:
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
回答21:
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
回答22:
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."
回答23:
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:
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.
回答24:
- Navigate to
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\
- Delete the
Git
folder
- Visual Studio
回答25:
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
回答26:
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.
回答27:
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
回答28:
It is my solution of this problem. I don't know why, but if I have an error during clone of project in Team Explorer menu, this way always work. Please see a screen.
回答29:
The below fixes my problem.
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 installation should be fine with VSTS and TF
Explorer.