自动合并冲突解决 [英] Automatic merge conflict resolution

查看:409
本文介绍了自动合并冲突解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行此命令时,我在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 theirsgit merge --strategy-option ours

在发生冲突时偏向源或目的地.在这里阅读有关它的更多信息:

To favor either the source or the destination when it comes to conflicts. Read more about it here:

解决Git合并冲突支持他们在拉动过程中的变化

https://git-scm.com/docs/merge-strategies

这篇关于自动合并冲突解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆