git Github Windows“无法同步此分支”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15387640/
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
Github Windows 'Failed to sync this branch'
提问by Nyxynyx
I am using Github Windows 1.0.38.1 and when I click the 'Sync' button after committing, I get the error
我正在使用 Github Windows 1.0.38.1,当我提交后单击“同步”按钮时,出现错误
How do I debug this problem? If in the shell, what should I do?
我如何调试这个问题?如果在shell中,我该怎么办?
The sync works fine if i do a git push
or git pull
, but the next time I want to sync using Github windows, I get the same error.
如果我执行 agit push
或git pull
,同步工作正常,但下次我想使用 Github windows 同步时,我得到同样的错误。
回答by manojlds
When it says that, just open the shell and do git status
. That will give you a decent idea of what could be wrong and the state of your repo.
当它说的时候,只需打开外壳并执行git status
. 这将使您对可能出错的地方以及您的回购状态有一个不错的了解。
I can't give you a specific error for this as it happens for many reasons in Github for Windows, like say some problem in updating submodules etc.
我不能给你一个具体的错误,因为它在 Windows 版 Github 中发生的原因有很多,比如更新子模块时出现一些问题等。
回答by Navin Mishra
This error comes because of a merge conflict in files. I faced it after I had updated my Maven Project's pom.xml but didn't commit it. Using
此错误是由于文件中的合并冲突引起的。在我更新了我的 Maven 项目的 pom.xml 但没有提交之后,我遇到了它。使用
git status
error: Your local changes to the following files would be overwritten by merge:
<my project>/pom.xml
Please, commit your changes or stash them before you can merge.
Aborting
as the above post suggested helped finding any conflicting changes and you can decide to discard or commit.
由于上面的帖子建议帮助找到任何冲突的更改,您可以决定放弃或提交。
回答by rk2
I had the same problem. It happened to me because of some conflicting changes. I removed the local repository of my project from my desktop and then cloned it again from the github website (using clone option in my account), the error was gone.
我有同样的问题。由于一些相互矛盾的变化,它发生在我身上。我从我的桌面上删除了我的项目的本地存储库,然后从 github 网站再次克隆它(在我的帐户中使用克隆选项),错误消失了。
回答by rovsen
I had the same problem when I tried from inside Visual Studio and "git status" in shell showed no problem. But I managed to push the local changes with "git push" via shell.
当我从 Visual Studio 内部尝试时遇到了同样的问题,并且 shell 中的“git status”显示没有问题。但是我设法通过 shell 使用“git push”推送本地更改。
回答by Tom
I had this problem and found it was to do with the proxy. I fixed the problem using this command:
我遇到了这个问题,发现它与代理有关。我使用以下命令修复了问题:
git config --global http.proxy %HTTP_PROXY%
回答by Steven
I had the same problem. In my case git could not find the global variable %HTTP_PROXY%
, simply because Windows was not providing/using it.
我有同样的问题。在我的情况下 git 找不到全局变量%HTTP_PROXY%
,仅仅是因为 Windows 没有提供/使用它。
I solved it by excluding the variable from the git config file (located in %USERPROFILE%\.gitconfig
):
我通过从 git 配置文件(位于%USERPROFILE%\.gitconfig
)中排除变量来解决它:
[http]
# proxy = %HTTP_PROXY%
回答by kwakwa
This is probably an edge case, but every time I've got this specific error it is because I've recently mapped a drive in Windows, and powershell
cannot find it.
这可能是一个极端情况,但每次我遇到这个特定错误时,都是因为我最近在 Windows 中映射了一个驱动器,powershell
但找不到它。
A computer restart (of all things) fixes the error for me, as powershell
can now pick up the newly mapped drive. Just make sure you connect to the mapped drive BEFORE opening the github client.
计算机重启(所有事情)为我修复了错误,因为powershell
现在可以拿起新映射的驱动器。只需确保在打开 github 客户端之前连接到映射驱动器。
回答by Ralph Lavelle
Have you changed your Windows password recently, or at least the one you use to connect to your proxy?
您最近是否更改了 Windows 密码,或者至少更改了用于连接代理的密码?
This was my problem, and git status
couldn't help me. I had to change my login credentials in the ".git/config" file to get past this error.
这是我的问题,git status
无法帮助我。我必须在“.git/config”文件中更改我的登录凭据才能克服此错误。
回答by Libby
This error also occurs if the branch you're trying to sync has been deleted.
如果您尝试同步的分支已被删除,也会发生此错误。
git status
won't tell you that, but you'll get a "no such ref was fetched" message if you try git pull
.
git status
不会告诉你,但如果你尝试git pull
.
回答by Corey
One more thing that can cause this is when you map a network drive or connect a VHD after GitHub Desktop has already been started. The reason for this is that GitHub Desktop uses ssh-agent from the portable GIT install to establish connections, and never closes it... even if you uninstall the application. The process starts with no knowledge of the new drive and never refreshes itself, and when it is used to run the GIT commands to work on your repo it fails because it doesn't understand the paths.
可能导致这种情况的另一件事是在 GitHub Desktop 启动后映射网络驱动器或连接 VHD。这样做的原因是 GitHub Desktop 使用便携式 GIT 安装中的 ssh-agent 来建立连接,并且永远不会关闭它……即使您卸载了应用程序。该过程在不知道新驱动器的情况下开始,并且永远不会自行刷新,并且当它用于运行 GIT 命令来处理您的存储库时,它会失败,因为它不了解路径。
The solution in this instance is to close GitHub Desktop and use Task Manager to terminate the running ssh-agent before starting it again. This will start a new instance of ssh-agent when needed which will pick up the new drive mappings, etc.
这种情况下的解决方案是关闭 GitHub Desktop 并使用任务管理器终止正在运行的 ssh-agent,然后再重新启动它。这将在需要时启动一个新的 ssh-agent 实例,它将获取新的驱动器映射等。