[英]Trying to merge two branches (one is very old, trying to pull master code) but there are conflicts in every file
the conflicts shouldn't even be conflicts... most of them are on the documentation I added, like tihs: 冲突甚至不应该是冲突...大多数冲突都在我添加的文档中,例如tihs:
<<<<<<< HEAD
# returns the max_sequence for this section
=======
>>>>>>> merged with other_branch_that_isnt_master
the command I did was git pull --rebase origin master
我做的命令是git pull --rebase origin master
but when I just do git pull origin master
, I still get tons of conflicts everywhere. 但是当我只是做git pull origin master
,到处仍然有很多冲突。
Why is it not merging appropriately? 为什么没有适当地合并? it's like git gave up on life. 就像git放弃了生命。
How do I get git to actually merge my files? 如何获得git实际合并我的文件?
I'm using git on Mac Lion. 我在Mac Lion上使用git。
It is likely that you committed to the wrong branch and had the branches diverge. 您可能选择了错误的分支并导致分支分歧。 This means that a rebase will no longer cleanly apply, creating conflicts. 这意味着重新基准将不再完全适用,从而产生冲突。
One option is to perform a git merge
and do the hard manual work of fixing the conflicts. 一种选择是执行git merge
并完成解决冲突的艰苦的手动工作。 Once the branches have merged, you should only need to do the work once. 分支合并后,您只需要做一次工作。
Another option is to ignore all of the changes in the other copy of master
and make your copy the authoritative one. 另一种选择是忽略master
另一个副本中的所有更改,并使您的副本具有权威性。 This is not recommended, but it depends on your use case: 不建议这样做,但这取决于您的用例:
git fetch
git merge -s ours origin/master
Another option is to rewrite and fix the commit history as Dave has suggested. 另一种选择是按照Dave的建议重写并修复提交历史记录。 A summary follows: 总结如下:
gitk --all
or git log --graph --all
to visualise the history and see where the branches have diverged. 使用gitk --all
或git log --graph --all
可视化历史记录,并查看分支的分支位置。 git reset --hard
to rewind history to that commit 使用git reset --hard
将历史回滚到该提交 git pull --rebase
做一个git pull --rebase
git cherry-pick
your commits back onto the rebased history, hopefully minimising conflicts. git cherry-pick
您的提交回到重新建立的历史上,希望将冲突降到最低。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.