526

After I pulled from remote branch, I got conflict, when I open the file it looks something like below:

<<<<<<< HEAD:file.txt
Hello world
=======
Goodbye
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt

I need some explanations of the markers, which portion of code is pulled from remote and which is from local?

What does the code 77976da35a11db4580b80ae27e8d65caf5208086 stand for?

Mellon
  • 37,586
  • 78
  • 186
  • 264

1 Answers1

835

The line (or lines) between the lines beginning <<<<<<< and ====== here:

<<<<<<< HEAD:file.txt
Hello world
=======

... is what you already had locally - you can tell because HEAD points to your current branch or commit. The line (or lines) between the lines beginning ======= and >>>>>>>:

=======
Goodbye
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt

... is what was introduced by the other (pulled) commit, in this case 77976da35a11. That is the object name (or "hash", "SHA1sum", etc.) of the commit that was merged into HEAD. All objects in git, whether they're commits (version), blobs (files), trees (directories) or tags have such an object name, which identifies them uniquely based on their content.

Nathan Wailes
  • 9,872
  • 7
  • 57
  • 95
Mark Longair
  • 446,582
  • 72
  • 411
  • 327
  • 7
    What does the code 77976da35a11 stands for then? – Mellon Oct 26 '11 at 11:21
  • 34
    7797... is the commit you tried to merge from. – Noufal Ibrahim Oct 26 '11 at 11:23
  • 2
    @Mellon that would be the SHA ID for the commit, where you got the changes, when you did the `pull` – Francisco Corrales Morales May 05 '14 at 23:39
  • 2
    Every time you make a commit - git computes a hash which is a function of the current content/code you have. So 7797 is the computed hash that depicts the commit you are merging. – Rose Oct 20 '15 at 22:55
  • 1
    is there software that knows how to render `git conflict format` and present it in two columns for merging? – dark_ruby Jun 09 '16 at 13:20
  • 2
    Is there any way to configure this so we have meaningful labels like branch names and commit ids ? Or are we stuck forever guessing how to work around git developer madness?? – Owl Oct 04 '16 at 13:49
  • 1
    Look for a 3 way merge tool. Will show 3 files - the common parent, your current branch version and the one you're pulling in side by side and highlight whats different. I use P4merge for complex conflicts - https://www.perforce.com/products/helix-core-apps/merge-diff-tool-p4merge – Jag Jan 18 '18 at 15:29
  • Simple and clean explanation. Beginners can refer https://help.github.com/en/articles/resolving-a-merge-conflict-using-the-command-line – VVB Feb 28 '19 at 07:26
  • I did not understand what I must do – Ahmed C Apr 14 '20 at 12:21
  • You can use tags to mark special points in the history, like releases. – doug65536 Jan 19 '22 at 03:38
  • 1
    for anyone looking for a more encompassing response that also covers `|||||||` markers see https://stackoverflow.com/a/56156537/314780 – Vivek Gani Apr 05 '22 at 02:32