Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

git - Whats the Proper usage of .gitattributes with 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 (?).

An example of my usage:

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].

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...