强制Git在合并过程中始终选择较新的版本? [英] Force Git to always choose the newer version during a merge?
问题描述
我们假设我 merge
git并且存在合并冲突。
我的问题是:我怎么能强迫git总是选择较新版本的冲突代码,所以我不需要手动解决冲突? 解决方案
它并不完全是更新的版本,但你可以告诉git始终使用 git merge branch -X our
来选择当前分支上的版本,或者更喜欢版本使用 git合并分支-X它们
。
从 man git-merge
:
我们的:
这个选项强制冲突的hunk通过支持我们的版本自动解决。来自另一棵不与
冲突的树的变化反映到合并结果。对于二进制文件,整个内容都是从我们这边拿来的。
他们:
这与我们的相反。
Let's assume I merge
git and there is a merge conflict.
My question is: how can I force git to always choose the newer version of code in conflict so I won't need to resolve the conflict by hand?
It is not exactly the "newer" version, but you can tell git to always prefer the version on the current branch using git merge branch -X ours
, or to prefer the version of the branch being merged, using git merge branch -X theirs
.
From man git-merge
:
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.
theirs:
This is the opposite of "ours".
这篇关于强制Git在合并过程中始终选择较新的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!