Git Conficts

Merge Conflict

Whenever we try to merge a file, we may run into the situation where git isn't able to automatically merge the files. In these cases we must manually merge the files. We may also choose to keep a specific version of the file.
  git merge master     
  Auto-merged index.html
  CONFLICT (content): Merge conflict in index.html
  Auto-merged index.html
  CONFLICT (content): Merge conflict in index.html
  Automatic merge failed; fix conflicts and then commit the result.

Keep Our Version

If we feel that our version of the file is correct we can use the following command to do so.
git checkout --ours index.html
#alternatively we could have done the following too:
git reset -- index.html
git checkout ORIG_HEAD -- index.html

Keep Their Version

If we feel that their version(version being merged into ours) is correct we can use the following command to do so.
git checkout --theirs index.html
#alternatively we could have done the following too:
git reset -- index.html
git checkout MERGE_HEAD -- index.html

Add new comment