- Published on
Better git conflict resolution between binaries with ---theirs and ---ours
- Kevin Old
Whichever framework I use (Catalyst,
Django, etc.) for personal projects, I
always develop with a local SQLite database. From time to time
they can get out of sync between branches. While working on a project
recently, I ran into a Git conflict between a SQLite
master and an older copy on a development branch.
After checking out the development branch, I ran the merge:
$ git checkout dev_branch $ git merge master
Git notified me that I had a conflicting SQLite file.
I posed the question on the Git irc channel and was told (thanks
doener) to use the
--theirs flag for
$ git checkout --theirs filename(s)
This says that the file(s) being merged in take precedence over the
file(s) in place in the branch, thus running this will overwrite the
file(s) on the branch.
--ours is the opposite in that the file(s) on
the branch take precedence in this merge. More information can be found
in the git-checkout
I was then able to complete the merge:
$ git add umerged_file(s) $ git commit
I'm not sure which version of Git this was made available in, but having just upgraded for this feature it is available in the latest stable version (currently 184.108.40.206).
In the old version I was running (220.127.116.11)
"git reset -- file; git checkout MERGE_HEAD -- file" would have done