git merge ,保留两者

标签 git git-merge

对于 merge ,我用它来“保留我的”

git merge -X ours foo

这是为了“保留他们的”

git merge -X theirs foo

然而,在我最近的 merge 中,最好保留双方。 Git 是否为此制定了“策略”来避免手动编辑文件?

最佳答案

没有解决这些冲突的“merge 策略”。

但是,如果您真的想要这样的冲突:

<<<< ours
Foo
=========
Bar 
>>>> theirs

解决

Foo
Bar

然后您可以配置“merge 驱动程序”。来自gitattributes手册页:

union

Run 3-way file level merge for text files, but take lines from both versions, instead of leaving conflict markers. This tends to leave the added lines in the resulting file in random order and the user should verify the result. Do not use this if you do not understand the implications.

向 .gitattributes 添加一行以使用它:

*.whatever merge=union

关于git merge ,保留两者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13263902/

相关文章:

当我切换分支时,Git 正在删除一个被忽略的文件

git - 如何在本地申请 Pull Request?

git - git 可以告诉我哪些未提交的文件与传入的更改冲突吗?

git - 使用 `git rebase` 更改旧提交消息

visual-studio-2010 - 从 GIT pull 时自动包含新添加的文件

git - 在 Git rebase 期间解决 merge 冲突后是否需要提交?

git - 限制开发人员访问 GitHub 存储库

Git pull - 无法提交 merge 消息

git - 颤振医生 - 错误 : Downloading Dart SDK from Flutter engine

linux - Git需要用户名和密码进行git push,git pull使用HTTPS方式