如何在非冲突合并的 GIT 中进行三向合并? [英] How to get 3-way merge in GIT on non-conflict merges?

查看:37
本文介绍了如何在非冲突合并的 GIT 中进行三向合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 GIT 中禁用自动合并?

How to disable auto-merging in GIT?

目的是在调用命令链期间与自动合并中的冲突合并解决具有相同的行为:

The purpose is to have the same behaviour as for conflict merges resolution in automatic merges during invocation of command chain:

$ git fetch
$ git merge some_branch
$ git mergetool

最后一个命令引导我们在合并冲突的情况下进行文件的 3 向合并.我想有一种简单的方法来在没有冲突合并的情况下对文件执行相同的三向合并.

The last command leads us to 3-way merge of files in case of merge conflicts. I would like to have an easy way of performing the same 3-way merge on files without conflict merges.

我在互联网上找不到任何解决方案,有吗?

I couldn't find any solution on the internet, is there any?

我有一些解决方法,但它更愿意避免它.

I've some workarounds in mind, but it would prefer to avoid it.

提前致谢,

亚历克斯

推荐答案

对于仅在一侧或另一侧进行的更改,您可以通过取消设置 merge 属性来防止自动合并(请参阅 gitattributes 在执行三向合并"下).为缺少合并属性(或将其设置为二进制")的路径名进行的合并将保留工作树中当前分支的版本,并使路径名的索引条目处于冲突状态.

For changes that were made only on one side or the other, you can prevent automatic merges by unsetting the merge attribute (see gitattributes under "Performing a three-way merge"). A merge made for a pathname that lacks the merge attribute (or has it set to "binary") will leave the version from the current branch in the working tree and leave the index entry for the pathname in a conflicted state.

如果你想鼓励每个人都这样工作,你可以放入一个 .gitattributes 文件并提交.如果你只想为自己做这件事,你可以把它放在一个未提交的 .gitattributes 文件中,或者把它放在你存储库的 $GIT_DIR/info/attributes 文件中(你可以随意添加/删除/重命名以启用/禁用该属性).

If you want to encourage everyone to work this way, you can put in into a .gitattributes file and commit it. If you only want to do this for yourself, you can put it in an uncommited .gitattributes files or put it in your repository's $GIT_DIR/info/attributes file (which you could add/remove/rename at will to enable/disable the attribute).

#    repository/.git/info/attributes
# OR
#    .gitattributes
* -merge

如果双方做相同的改动,即使这样配置也不会造成冲突.

If an identical change is made on both sides, even this configuration will not cause a conflict.

这篇关于如何在非冲突合并的 GIT 中进行三向合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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