Visual Studio 2017 - Git 失败并出现致命错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42667928/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:51:34  来源:igfitidea点击:

Visual Studio 2017 - Git failed with a fatal error

gitvisual-studioazure-devopsvisual-studio-2017

提问by Toby

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:

我正在使用 Visual Studio 2017 社区版 (CE),并且我已登录我的 Microsoft 帐户并连接到 VSTS。我可以看到我所有的项目和存储库,但是当我尝试拉/取/推送任何更改时,我收到以下错误:

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.

因此,对于 fetch 和 pull 命令也是如此。

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 2017 安装程序上安装了适用于 Windows 的 Git,它不仅无法与 VSTS 一起使用,而且我也无法使用我的任何 GitHub 存储库。有没有其他人注意到这一点?到目前为止,它发生在我的两台机器上。

Visual Studio 2015 Enterprise Edition (EE) and CE work completely fine for me.

Visual Studio 2015 企业版 (EE) 和 CE 对我来说完全正常。

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.

似乎这个问题得到了更多的认可,我认为这让我相信这是 Visual Studio 如何处理 Git 的问题。我还注意到,每次更新 Visual Studio 时,这个问题都会再次出现,我必须通过下面的一些答案中的步骤才能让 Git 再次工作。我不确定为什么会发生这种情况,我也不知道 Microsoft 是否计划解决此问题。

回答by wbing520

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

在我从Control PanelUser AccountsCredential Manager for Git更改通用凭证后,它对我有用

Enter image description here

在此处输入图片说明

回答by Toby

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

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

  1. 导航到C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\并删除该Git文件夹。

  2. 确保您的系统上没有安装 Git 版本,通过转到控制面板程序和功能将其删除(根据我的经验,TortoiseGit 不需要删除,只需要本地 git 安装)。

  3. 打开 Visual Studio 2017 安装程序并在安装选项中取消勾选“Git For Windows”。

  4. 前往Git 网站并安装适用于 Windows 的最新版本的 Git。

  5. 返回 Visual Studio 安装程序并再次勾选“Git for Windows”。即使它看起来像,它也不会下载新版本。完成后,您的 Git 应该可以与 VSTS 和 TF Explorer 配合使用。

回答by flatrick

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.dlland ssleay32.dllfrom one folder to another folder within the Git folders of Visual Studio 2017.

我有一个不同的问题。我的电脑包含在SYSTEM32和SysWOW64中年长的OpenSSL DLL文件,所以要解决我的问题,我不得不复制 libeay32.dllssleay32.dll从一个文件夹到Visual Studio 2017年的Git的文件夹内的另一个文件夹。

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

发件人: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

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

参考:Git - 无法克隆远程存储库

回答by AngelBlueSky

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

我尝试了很多,最后通过我在Git 中读取的内容进行了一些修改,使其工作- 无法克隆远程存储库

  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.

  1. 修改Visual Studio 2017 CE安装→删除Git for windows(安装程序→修改→单个组件)。

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

  3. 修改Visual Studio 2017 CE安装→添加Git for windows(安装程序→修改→单个组件)

  4. 在 Windows(32 或 64 位版本)上安装 Git,并在系统路径中配置 Git。

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

也许第 2 点和第 3 点是不需要的;我没有尝试。

Now it works OK on my Gogs.

现在它可以在我的 Gogs 上正常工作。

回答by Abdellah Azizi

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

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

and Retry..

并重试..

Enjoy !

享受 !

回答by JerryGoyal

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

我尝试了所有以前的方法,但它们都不起作用。后来我发现代码中存在一些冲突(参见Visual Studio 2017输出窗口)。

I simply reverted the code and it worked.

我只是恢复了代码并且它起作用了。

回答by ZenekMetalGuru

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 中遇到过这样的错误(我尝试发送我的提交,同时我的同事有待处理的更改):

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

Git 因致命错误而失败。pull --verbose --progress --no-edit --no-stat --recurse-submodules=no origin

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

事实证明,在按下Commit all按钮创建本地提交后,Visual Studio 留下了一个未提交的文件,这个详细说明的错误消息实际上意味着:“提交所有更改”。

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.

丢失的文件是 Entity Framework 6 模型,尽管您没有更改其中的任何内容,但它通常显示为未提交的文件。

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

您可以全部提交或撤消所有未提交的更改。

回答by 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.

这似乎发生在 VS 2017 中,当存在与拉取冲突的未决提交时。如果您转到命令终端并执行“git pull origin”,您通常会收到导致混淆的错误。要解决此问题,请检查 VS 2017 中的所有更改,然后再次尝试从 VS 2017 中拉取或同步。不用说……这不是 VS 2017 中想要的行为。

回答by éric Bergeron

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

我遇到过同样的问题。重新启动 Visual Studio对我有用...您可以在重新安装之前尝试一下。

回答by Avius

I'm using GitKraken and Visual Studio 2017.

我正在使用 GitKraken 和 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".

当 GitKraken 克隆存储库时,它会留下像“[email protected]:user/Repo.git”这样的获取地址,而不是“ https://github.com/user/Repo.git”。

To fix that, go to Team ExplorerSettingsRepository SettingsRemotesEdit, and change "git@" to "https://" and":" to "/".

要解决此问题,请转到Team ExplorerSettingsRepository SettingsRemotesEdit,并将“git@”更改为“https://”并将“:”更改为“/”。