自动合并冲突解决 [英] Automatic merge conflict resolution
问题描述
运行此命令时,我在index.js
中遇到合并冲突:
I get a merge conflict in index.js
when running this:
$ git checkout feature
$ git merge master
feature
分支index.js
const a = 1;
const b = 1;
master
分支index.js
(这是feature
分支的诞生地)
The master
branch index.js
(This is where feature
branch was born)
const a = 1;
master
分支index.js
(当前状态)
const a = 2;
我想以某种方式自动解决冲突,以便将feature
分支上的index.js
更新为此:
I want automatically resolve the conflict in such a way so that index.js
on feature
branch was updated to this:
const a = 2;
const b = 1;
推荐答案
就像提到的注释一样,Git只能决定如何将代码组合在一起.您可能对合并策略选项感兴趣.您可以运行
Like the comments mentioned, Git is only so good at deciding how to put code together. You might be interested in merge strategy options though. You can run
git merge --strategy-option theirs
或git merge --strategy-option ours
在发生冲突时偏向源或目的地.在这里阅读有关它的更多信息:
To favor either the source or the destination when it comes to conflicts. Read more about it here:
https://git-scm.com/docs/merge-strategies
这篇关于自动合并冲突解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!