The most common cause of merge conflicts happens when another user changes the same file that you just modified. It can happen during pull from a remote repository (or when merging branches).
git checkout --theirs conflicted_file.txt
git checkout --ours conflicted_file.txt
=> You still have to git add
and git commit
after this
<<<<<<< HEAD
local version (ours)
=======
remote version (theirs)
>>>>>>> [remote version (commit#)]
=> You still have to git add
and git commit
after this
During this process, if you want to roll back to the situation before you started the merge: git merge --abort
NOTE: By doing a pull
before committing, you can avoid a lot of git conflicts. Your git workflow should therefore be:
git add
git pull
commit -m "descriptive message"
git pull
git push
Continuing with the dessert
example we used in the first part of this tutorial, we now have on our local machine