Both MrA and MrB edited the same part of the file, hence the merge conflict.
I'm guessing you are getting this message when pulling:
error: Your local changes to the following files would be overwritten by merge:
file.txt
Please, commit your changes or stash them before you can merge.
Aborting
Solution (Steps MrB should do)
- Do
git commit
. This step should not fail. Although he could stash, I don't recommend it. - Do a
git pull
. This will result in the merge conflict, as expected. - Use
git mergetool
to bring up a GUI to aid in merging. Alternatively, just open the file up and edit it by hand to what you want. Git uses a special syntax to denote where the conflict is. See my link on branching and merging. - Do
git add
on the file. - Do
git commit
and now you've finished resolving the merge.
Reference material
- How to resolve merge conflicts in Git?
- http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging
- http://git-scm.com/book/en/Git-Tools-Stashing
As for git stash
, This will save all of your modified tracked files and staged changes. It essentially makes your copy of the text file unmodified. It stores the changes you made internally, but without committing. So when you pull, there is no conflict. However as @nneonneo points out, when you try to recover your changes with git stash pop
, you will get a conflict. I don't recommend this approach.