Showing posts with label difftool. Show all posts
Showing posts with label difftool. Show all posts

Sunday 18 December 2016

simple way to resolve merge conflicts in git

In most cases, solution to merge-conflict is as simple as discarding local changes or remote/other branch changes.
Following is useful in those cases…
1. Search for all conflicting files.
grep -lr '<<<<<<<' .
2. At this point you may review each files. If solution is to accept local/our version, run:
git checkout --ours PATH/FILE
3. If solution is to accept remote/other-branch version, run:
git checkout --theirs PATH/FILE
4. If you have multiple files and you want to accept local/our version, run:
grep -lr '<<<<<<<' . | xargs git checkout --ours
5. If you have multiple files and you want to accept remote/other-branch version, run:
grep -lr '<<<<<<<' . | xargs git checkout --theirs