Tuesday, October 22, 2013

git - how to resolve 'merge' related conflicts


1. Current version's changes are shown on top (alongwith HEAD text)
    Version being merged is shown at the bottom.

2. We need to resolve the code conflicts and then do a
    git   add  
    git   commit

Have to look at these links also -
http://githowto.com/resolving_conflicts
http://stackoverflow.com/questions/161813/how-do-i-fix-merge-conflicts-in-git
https://help.github.com/articles/resolving-a-merge-conflict-from-the-command-line
And I look at the file in our text editor, we see that git stuck the current version (HEAD, branch B) and the version being merged (branch A) together so we can resolve the conflict.
rawr
<<<<<<< HEAD
changed in branch B
=======
changed in branch A
>>>>>>> branch-a
Now I'll edit the file to make it look the way I want. This can be anything, I am not limited to using the version from one of the branches. In this case I put in a whole new version of the line that reflects what happened.
rawr
changed in both branches
I'm happy with this version, so we stage it and commit. I don't use the -m flag this time, so git opens our text editor pre-filled with a commit message describing the merge conflict. I go ahead and commit with that message.

No comments:

Post a Comment

Followers

Blog Archive