I have the following directory structure:
/.git
/.git/info/attributes
/MyProject
/MyProject/pom.xml
/MyProject/MyCode.java
I have branch master and bugfix. On both branches pom.xml and MyCode.java were modified. i would like to merge changes from bugfix to master only for MyCode.java and keep master version of pom.xml file.
So I added "/.git/info/attributes" because i don't want to commit .gitattributes with the project
$cat .git/info/attributes
pom.xml merge=ours
$git status
# On branch master
nothing to commit (working directory clean)
$git check-attr -a pom.xml
pom.xml: merge: ours
Finally to the problem:
When I do:
$git merge bugfix
Auto-merging MyProject/pom.xml
CONFLICT (content): Merge conflict in MyProject/pom.xml
Automatic merge failed; fix conflicts and then commit the result.
Git is ignoring attributes setting. What am i missing here?
I prefer not to define "keepMine.sh" per this post
this post is what i need, however i prefer not to go file by file if i have a simple pattern
thanks!
For locally-modified files:
$ git config merge.ours.driver true
or even
$ git config --global merge.ours.driver true
'ours' isn't one of the built-in merge drivers even though it's perfectly clear to you and me what it should do, and it seems git doesn't error out when a custom merge driver is undefined.
(true
above is just the unix true
command, its success says it made the local version look right, in this case by doing nothing to it.)
If the local version isn't or might not be modified since the base you'll have to script this, for instance, you can have a post-checkout hook construct branch-specific content, basically a quick-n-dirty make
, but by far the easiest is to set this up and add the branch name as a comment in each branch whose version you want to stay untouched.