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 masterbranch. and a feature_swapbranch. I want to continue working on these two branches in parallel. I did some change on masterand then committed. I wanted to apply some algorithm changes of masterto feature_swapbranch 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 pushyet. 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 pullis git fetch && git merge, the merge isn't unexpected.
考虑到git pullis的定义git fetch && git merge,合并并不意外。
You might want to to do git rebase masterinstead, which will reapply the commits in masteronto feature_swap. Combined with cherry-pickyou can specify the commits you want.
您可能想要改为这样做git rebase master,这会将提交重新应用master到feature_swap. 结合cherry-pick你可以指定你想要的提交。
To fetchfrom the remote, simply use git fetchwhich will download the commits from the remote but doesn't apply them.
为了fetch从遥控器,只需使用git fetch它们可以从远程下载的提交,但不应用它们。

