git pull 自动合并
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12645787/
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
git pull merges automatically
提问by Dipro Sen
I've a master
branch. and a feature_swap
branch. I want to continue working on these two branches in parallel. I did some change on master
and then committed. I wanted to apply some algorithm changes of master
to feature_swap
branch and see how that version works. So I did
我有一个master
分支。和一个feature_swap
分支。我想继续在这两个分支上并行工作。我做了一些改变master
,然后承诺。我想的有些算法更改适用master
于feature_swap
分支,看到的版本是如何工作的。所以我做了
git pull origin feature_swap
and got this message
并收到此消息
* branch feature_swap -> FETCH_HEAD
Auto-merging collator.h
Merge made by recursive.
I don't want to merge. rather I just want to put some selected changes that I applied on master to feature_swap (may be by copy pasting). and If That fits my expectation I'll make another commit to that branch with those changes. which I again want paralally.
我不想合并。相反,我只想将我在 master 上应用的一些选定更改添加到 feature_swap (可能是通过复制粘贴)。如果这符合我的期望,我将通过这些更改再次提交该分支。我再次想要平行。
I am afraid, I'vent done a git push
yet. I can see Merge branch 'feature_swap'
in git log
. What I need to do now to restore the state ?
恐怕,我还没做完git push
呢。我可以看到Merge branch 'feature_swap'
在git log
。我现在需要做什么来恢复状态?
回答by Femaref
Considering the definition of git pull
is git fetch && git merge
, the merge isn't unexpected.
考虑到git pull
is的定义git fetch && git merge
,合并并不意外。
You might want to to do git rebase master
instead, which will reapply the commits in master
onto feature_swap
. Combined with cherry-pick
you can specify the commits you want.
您可能想要改为这样做git rebase master
,这会将提交重新应用master
到feature_swap
. 结合cherry-pick
你可以指定你想要的提交。
To fetch
from the remote, simply use git fetch
which will download the commits from the remote but doesn't apply them.
为了fetch
从遥控器,只需使用git fetch
它们可以从远程下载的提交,但不应用它们。