解决Git合并冲突有利于他们在拉动过程中的变化
如何解决git合并冲突以支持所做的更改?
基本上,我需要从工作树中删除所有冲突的更改,而不必通过git mergetool
完成所有冲突,同时保留所有无冲突的更改。 最好在拉动的同时进行,而不是之后。
您可以使用递归“他们”策略选项:
git merge --strategy-option theirs
来自男子:
ours
This option forces conflicting hunks to be auto-resolved cleanly by
favoring our version. Changes from the other tree that do not
conflict with our side are reflected to the merge result.
This should not be confused with the ours merge strategy, which does
not even look at what the other tree contains at all. It discards
everything the other tree did, declaring our history contains all that
happened in it.
theirs
This is opposite of ours.
请注意:正如手册页所述,“我们的”合并策略选项与“我们的”合并策略截然不同。
git pull -s recursive -X theirs <remoterepo or other repo>
或者,简单地说,对于默认存储库:
git pull -X theirs
如果你已经处于冲突状态......
git checkout --theirs path/to/file
如果你已经处于冲突状态,并且你想接受他们所有的状态:
git checkout --theirs .
git add .
如果你想做相反的事情:
git checkout --ours .
git add .
这是非常激烈的,所以确保你在做之前真的想把所有东西都擦掉。
链接地址: http://www.djcxy.com/p/1199.html上一篇: Resolve Git merge conflicts in favor of their changes during a pull