在将分支A合并到分支B时,Git报告了几个冲突。我想通过保留每个文件的分支A的版本来解决冲突。我不关心分支B中的内容。
是否有一个命令我可以通过保留我的文件版本(分支A中的版本)来解决所有合并冲突?
答案 0 :(得分:3)
事实上,使用Git的术语,你想要丢弃“我们的”并保留“他们的”。这是因为当您进行合并时,您在分支B 上,这使得它成为“我们的”。
git checkout B
git merge -s recursive -X theirs A
来自文档:
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.