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
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.As mentioned in ".gitattributes & individual merge strategy for a file":
You can see an example of concurrent modification (ie modification in both branches) in "How do I tell git to always select my local version for conflicted merges on a specific file?".
So if your merges didn't involve modifications of the same files within
cache/
folder in both branches, your merge driver was never called.But in your case, for files with different settings, I would recommend not using a merge driver, but a content filter driver, as in "Keep settings in branch"
That allows you to keep in version control:
cache/
folder