When there's a merge conflict in Git, junk like the following is inserted into the conflicting files. Three questions:
Note: In case it's relevant, I am using GitHub's Mac GUI client.
A merge conflict is an event that occurs when Git is unable to automatically resolve differences in code between two commits. When all the changes in the code occur on different lines or in different files, Git will successfully merge commits without your help.
Everything between <<<<<<
and ======
comes from the HEAD
revision, which is the committed state before starting the merge operation (git merge
will complain if the tree is dirty, so it should be equivalent to your working directory).
The parts between ======
and >>>>>>
come from the version being merged. The text after the >>>>>>
is the comment of the commit that introduced the conflicting change.
That there is a conflict marker means that the base version of this part of the file is different from both "new" versions. The base version (last common ancestor) is not shown.
If you want a more comfortable merge and have a GUI available, I suggest you take a look at kdiff3.
There's now a better solution than trying to read the gibberish markers that Git inserts into your files. Kaleidoscope 2, Black Pixel's second release of their diff tool, is now also a merge tool. It's not free, but it works beautifully.
After you install Kaleidoscope 2, it's really simple to integrate with Git. Open Kaleidoscope and from the Menu Bar choose Kaleidoscope > Integration…
Then you'll see this window. Simply choose Git from the left nav and then install the ksdiff
command-line tool and then make Kaleidoscope Git's default diff and merge tool.
Finally, once you have a merge conflict in Git, simply go to the command line and execute git mergetool
. Now the conflict is easy to read. Enjoy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With