您正在寻找recursive
带有选项的策略theirs
。
git pull -s recursive -X theirs
从 git-pull 手册页:
recursive
This can only resolve two heads using a 3-way merge algorithm. When
there is more than one common ancestor that can be used for 3-way
merge, it creates a merged tree of the common ancestors and uses that
as the reference tree for the 3-way merge. This has been reported to
result in fewer merge conflicts without causing mis-merges by tests
done on actual merge commits taken from Linux 2.6 kernel development
history. Additionally this can detect and handle merges involving
renames. This is the default merge strategy when pulling or merging
one branch.
The recursive strategy can take the following options:
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. For a
binary file, the entire contents are taken from our side.
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 the opposite of ours.
然而,这确实不是一个好主意。即使您相信上游的更改是正确的,您如何知道它们与您的更改一起工作而不会导致冲突?
我个人更喜欢git pull --rebase
直截了当,git pull
并逐个检查每个冲突的提交。