无法合并两台计算机的更改
我的解决方案存储在GitHub上,我正在使用Visual Studio的内置功能来检查内外的代码。目前,我是唯一从事我项目的人。但是我已经开始在不同的计算机之间切换。
每当我到达两台计算机都进行待处理的地方时,我都无法继续。
我正在尝试在一台计算机上推动我的更改,这给了我一个错误:
由于您的本地分支在远程分支后面,因此无法推动远程存储库。在推动之前拉动分支。
[拉然后推] [拉] [取消]
如果我选择[pull then stuph]
,我会遇到不同的错误。
拉力操作失败。有关详细信息,请参见输出窗口。
输出窗口显示以下内容。
Pushing master
Hint: You have divergent branches and need to specify how to reconcile them.
Hint: You can do so by running one of the following commands sometime before
Hint: your next pull:
Hint:
Hint: git config pull.rebase false # merge
Hint: git config pull.rebase true # rebase
Hint: git config pull.ff only # fast-forward only
Hint:
Hint: You can replace "git config" with "git config --global" to set a default
Hint: preference for all repositories. You can also pass --rebase, --no-rebase,
Hint: or --ff-only on the command line to override the configured default per
Hint: invocation.
Git failed with a fatal error.
Git failed with a fatal error.
Need to specify how to reconcile divergent branches.
两个系统都显示当前分支为 master 。我期望将更改合并,所以我不确定为什么这是一个问题。
有什么方法可以让视觉工作室合并更改并让我处理任何冲突?
注意:我正在尝试阅读此信息,但我没有为此使用命令行。我很想只使用IDE。似乎应该支持我要做的事情。我所读的内容似乎表明我需要在拉动设置时设置 rebase本地分支,但是我不确定我应该设置什么或为什么。
My solution is stored on GitHub and I'm using the built-in features of Visual Studio to check code in and out. Currently, I'm the only one working on my project. But I've started switching between different computers.
Every time I get to where both computers have pending changes, I am unable to continue.
I'm trying to push my changes on one computer and it gives me an error:
Unable to push the remote repository because your local branch is behind the remote branch. Update your branch by pulling before pushing.
[Pull then Push] [Pull] [Cancel]
If I select [Pull then Push]
, I get a different error.
The pull operation failed. See the Output window for details.
And the Output window shows the following.
Pushing master
Hint: You have divergent branches and need to specify how to reconcile them.
Hint: You can do so by running one of the following commands sometime before
Hint: your next pull:
Hint:
Hint: git config pull.rebase false # merge
Hint: git config pull.rebase true # rebase
Hint: git config pull.ff only # fast-forward only
Hint:
Hint: You can replace "git config" with "git config --global" to set a default
Hint: preference for all repositories. You can also pass --rebase, --no-rebase,
Hint: or --ff-only on the command line to override the configured default per
Hint: invocation.
Git failed with a fatal error.
Git failed with a fatal error.
Need to specify how to reconcile divergent branches.
Both systems show the current branch is master. I was expecting the changes to be merged so I'm not sure why this is a problem.
Is there any way to get Visual Studio to merge the changes and allow me to deal with any conflicts?
Note: I'm trying to read up on this but I am not using a command line for this. I would far prefer to just use the IDE. And it seems like it should support what I'm trying to do. What I've read seems to indicate I need to set the Rebase local branch when pulling setting, but I'm not sure what I should set it to or why.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在Visual Studio 2019或更高版本上,则应该能够关注这些说明以设置项目项目的
git pull
策略。此答案
对您从Git看到的警告进行了详尽的解释。基本上,
git
希望您设置一种配置,以告诉它如何处理您试图更新与本地分支有所不同的远程分支的情况。将其设置为false
将为您提供您可能使用的行为,但我更喜欢true
个人。在Visual Studio中设置配置(或Git建议的命令行中)将解决错误。至于您应该选择哪种选项进行配置,这确实取决于您。但是,我将简要概述每个选项:
。
false
。,这将不会自动使用默认行为。
true
的高级版本。在您倾向于在本地进行大量小型投入的情况If you're on Visual Studio 2019 or above, you should be able to follow these instructions to set the
git pull
strategy for your project.This answer
gives a thorough explanation of the warning that you're seeing from Git. Basically,
git
wants you to set a configuration to tell it how to handle situations where you're attempting to update a remote branch that has diverged from your local branch. Setting it toFalse
will give you the behavior that you're probably used to, but I preferTrue
personally.Setting the configuration in Visual Studio (or at the command line, as suggested by git), will resolve the error. As for which option you should choose for the configuration, that's really up to you. But I'll give a brief overview of each option:
False
.True
. Useful in the case where you tend to make a lot of small commits locally, since it will give you an opportunity to rewrite your local commit history.