.gitattributes 与 merge=ours 的正确用法是什么 [英] Whats the Proper usage of .gitattributes with merge=ours
问题描述
我第一次尝试使用 .gitattributes.我想我一定是做错了什么,因为它不起作用,因为我认为使用 merge=ours
属性的目的是为了 (?).
I just tried using .gitattributes for the first time. I figure I must be doing something wrong because it is not working as I thought the purpose of using the merge=ours
attribute was intended for (?).
我的用法示例:
我有两个分支;一个是大师",另一个是GCE-Site".GCE-Site"分支上的文件具有不同的设置,这些文件也存在于master"分支上,我不想将它们合并到master"[或其他分支]中.
I have two branches; one is the "master" and the other is "GCE-Site". There are files on the "GCE-Site" branch that have different settings that also exists on the "master" branch that I do not want merging into the "master" [or other branches].
在两个分支上,我都有一个 .gitattributes
包含以下规则:
On both branches, I have a .gitattributes
containing the following rules:
README.md merge=ours
config.php merge=ours
.gitattributes merge=ours
.gitignore merge=ours
.cache/ merge=ours
所有需要规则的文件都在根级别加上 .cache/文件夹之上的所有内容.当我执行 git merge GCE-Site
时,当我不想要的时候,所有文件仍然合并到 master 中.
All the files needing the rules are on the root level plus everything above the .cache/ folder. When I do a git merge GCE-Site
, all files still merge into the master when I don't want that.
有什么我遗漏的吗?非常感谢您的帮助.谢谢
Is there something I am missing? Your help is greatly appreciated. Thnx
推荐答案
一旦我知道自己在做什么就可以轻松解决:我错过了使用 git config --global merge.ours.driver true 添加合并策略代码> 在我的本地环境中.
Easy fix once I knew what I was doing: I missed adding the merge strategy with git config --global merge.ours.driver true
in my local environment.
这篇关于.gitattributes 与 merge=ours 的正确用法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!