【发布时间】:2014-01-29 14:28:53
【问题描述】:
在将分支 A 合并到分支 B 时,Git 报告了几个冲突。我想通过保留分支 A 的每个文件的版本来解决冲突。 B分支的内容我不关心。
是否有一个命令可以通过保留我的文件版本(分支 A 中的版本)来解决所有合并冲突?
【问题讨论】:
在将分支 A 合并到分支 B 时,Git 报告了几个冲突。我想通过保留分支 A 的每个文件的版本来解决冲突。 B分支的内容我不关心。
是否有一个命令可以通过保留我的文件版本(分支 A 中的版本)来解决所有合并冲突?
【问题讨论】:
事实上,使用 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.
【讨论】: