git .gitattributes 合并策略

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9264701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:28:40  来源:igfitidea点击:

.gitattributes merge strategy

git

提问by thesonix

I tried to add a merge strategy to my .gitattributes file in my repository. But when I merge another branch with that (different) file it results in a merge-conflict - auto merge failed.

我尝试向我的存储库中的 .gitattributes 文件添加合并策略。但是当我将另一个分支与该(不同的)文件合并时,它会导致合并冲突 - 自动合并失败。

Here's what I try to do.

这就是我尝试做的。

.gitattributes:

.git 属性:

backend/library/project/config.php merge=ours

Branches:

分支机构:

  • production
  • staging
  • 生产
  • 分期

in production I have config.php'A and in staging I have config.php'B.

在生产中,我有 config.php'A,在暂存时我有 config.php'B。

> git checkout production

> git merge staging 

> Auto-merging backend/library/project/config.php
> CONFLICT (content): Merge conflict in backend/library/project/config.php
> Automatic merge failed; fix conflicts and then commit the result.

I tried adding the line to .git/info/attributes as well as adding quotes to ..merge="ours".

我尝试将该行添加到 .git/info/attributes 以及将引号添加到 ..merge="ours"。

Has anybody an idea what I am doing wrong? (Git-version is 1.7.4.4) thx

有人知道我做错了什么吗?(Git 版本是 1.7.4.4)谢谢

采纳答案by ulmangt

There are two excellent Stack Overflow responses which address this problem:

有两个很好的 Stack Overflow 响应可以解决这个问题:

How do I tell git to always select my local version for conflicted merges on a specific file?

我如何告诉 git 总是为特定文件上的冲突合并选择我的本地版本?

and

.gitattributes & individual merge strategy for a file

.gitattributes & 单个文件的合并策略

I'd suggest reading through the top answer in the first link. It's long, but very detailed and informative.

我建议通读第一个链接中的最佳答案。它很长,但非常详细和翔实。