I am working through the Git - Rerere section of the Git Book. I have just run git checkout master; git merge rerere2; git rerere diff
. Here is the output.
PS> git rerere diff
--- a/simple.rb
+++ b/simple.rb
@@ -1,9 +1,9 @@
#! /usr/bin/env ruby
def hello
-<<<<<<<
- puts 'hello mondo'
-=======
+<<<<<<< HEAD
puts 'hola world'
->>>>>>>
+=======
+ puts 'hello mondo'
+>>>>>>> rerere2
end
There are three diff sections.
<<<<<<<
shows what?<<<<<<< HEAD
shows what theHEAD
branch wants to contribute.>>>>>>> rerere2
shows what thererere2
branch wants to contribute.
It looks like the first diff section is a negation of what rerere2
wants to contribute. That doesn't make sense to me, though. What does the first section mean?
Answer
Asking what the first section of
git rerere diff
means is fine but misguided. Instead, examine the-
and+
annotations. From the Git Book:Anything prefixed with
-
orno prefix
is what you started with to resolve:Anything prefixed with
+
orno prefix
is what you've resolved it to (and is what you currently have in your working dir):Detailed Explanation
Contents of Working Dir
Immediately after merge, the working directory contains:
Output of
git diff
The output of
git diff
is this and uses the combined diff markup:If we look at the working dir file of simple.rb, this is true. It's contents are the same as the
git diff
output but without the ours/theirs markers.Output of
git rerere diff
And the output of
git rerere diff
is this and does NOT use the combined diff format.-
is part of what you've started with+
is part of what you've resolved toIf we look at just what has the
-
annotation, we have this:That says that the left side brings in
puts 'hello mondo'
and the right side brings in nothing. If we look at just what has the+
, we have this:That's exactly what is in the working directory right now.