Studyon Minte9.com
Git




Merge force




$ git merge dev -X theirs $ git merge dev -X ours
1) Modification in master
$ git init (master) $ touch example.txt $ echo "master line" > example.txt $ git add . $ git commit -m "master commit"
2) Modification in dev
(dev) $ git checkout -b dev $ echo "dev line 2" > example.txt $ git -m -a "m" $ less example.txt dev line 2 // add a line which will conflict with master (master) $ git checkout master
3) Try merge (gets conflict)
$ git merge dev Auto-merging example.txt CONFLICT (content): Merge conflict in example.txt Automatic merge failed; fix conflicts and then commit the result. $ less example.txt <<<<<<< HEAD master line ======= dev line 2 >>>>>>> dev (master|MERGING) $ git merge dev -X theirs error: 'merge' is not possible because you have unmerged files ...
4) Commit reset
// Undo merge one step $ git reset --hard HEAD~1 HEAD is now at d5f8b30 m $ git status # On branch master nothing to commit, working directory clean
5) Merge force (keep theirs)
// Merge and keep DEV modifications $ git merge dev -X theirs $ less example.txt dev line // master file contains now their line


http://stackoverflow.com/questions/13594344/git-merge-force