co.de.mon.key

Weblog

Git force merge strategy for specific file

| Comments

In order to set a default strategy for a file(s) in git merge you need to:

Enable the ours merge driver

  • for current repository
1
git config merge.ours.driver true
  • globally
1
git config --global merge.ours.driver true

Tell git to use the merge strategy for a file

1
echo "solutionfolder/file.xml merge=ours" >> .git/info/attributes

As a result the next pull with conflicts will automagically use ours version.

Just remember that the file will not longer be marked as merge conflict.

inspiration

Comments