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!
git merge -s ours. The ours strategy is simple: it discards all changes from the other branch. This leaves the content on your branch unchanged, and when you next merge from the other branch, Git will only consider changes made from this point forward.
$ 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 you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With