git rerere diff 输出中的第一部分是什么



我正在通过Git Book的Git - Rerere部分工作。我刚刚跑了git checkout master; git merge rerere2; git rerere diff.这是输出。

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

有三个差异部分。

  1. <<<<<<<显示什么?
  2. <<<<<<< HEAD显示了HEAD分支想要贡献的内容。
  3. >>>>>>> rerere2显示了rerere2分支想要贡献的内容。

看起来第一个差异部分否定了rerere2想要贡献的内容。不过,这对我来说没有意义。第一部分是什么意思?

答案

git rerere diff的第一部分是什么意思很好,但被误导了。相反,请检查-+批注。来自 Git Book:

git rerere diff将显示解决方案的当前状态 - 您开始解析的内容以及已解决的内容。

任何以 -no prefix 为前缀的内容都是您开始解决的问题:

<<<<<<<                           
  puts 'hello mondo'              
=======
  puts 'hola world'                           
>>>>>>>

任何以 +no prefix 为前缀的内容都是您已解析的内容(也是您当前在工作目录中的内容(:

<<<<<<< HEAD                      
   puts 'hola world'               
=======                           
  puts 'hello mondo'              
>>>>>>> rerere2                   

详细解释

工作目录的内容

合并后,工作目录立即包含:

def hello
<<<<<<< HEAD
  puts 'hola world'
=======
  puts 'hello mondo'
>>>>>>> rerere2
end

git diff输出

git diff 的输出是这样的,并使用组合的差异标记:

  def hello
++<<<<<<< HEAD                    in working dir but in neither ours/theirs
 +  puts 'hola world'             in working dir but not in theirs
++=======                         in working dir but in neither ours/theirs
+   puts 'hello mondo'            in working dir but not in ours
++>>>>>>> rerere2                 in working dir but in neither ours/theirs
  end

如果我们看一下simple.rb的工作目录文件,这是真的。它的内容与git diff输出相同,但没有我们/他们的标记。

git rerere diff输出

git rerere diff的输出是这样的,不使用组合的 diff 格式。

 def hello                              
-<<<<<<<                            started with
-  puts 'hello mondo'               started with
-=======                            started with
+<<<<<<< HEAD                       resolved to
   puts 'hola world'                started with & resolved to
->>>>>>>                            started with
+=======                            resolved to
+  puts 'hello mondo'               resolved to
+>>>>>>> rerere2                    resolved to
 end
  • 任何有-的东西都是你开始的一部分
  • 任何有+的事情都是你决心的一部分
  • 任何没有前缀的东西都是两者的一部分

如果我们只看一下具有-注释的内容,我们会得到:

-<<<<<<<                           
-  puts 'hello mondo'              
-=======                           
->>>>>>>

也就是说,左侧带来了puts 'hello mondo'而右侧什么都没有。如果我们只看一下 什么有 + ,我们有这个:

+<<<<<<< HEAD                      
   puts 'hola world'               
+=======                           
+  puts 'hello mondo'              
+>>>>>>> rerere2                   

这正是现在工作目录中的内容。

从该链接

Git rerere diff 将显示解决方案的当前状态 - 您开始解析的内容以及已解析的内容。

Git Rerere 保存合并选项。所以它描述了它将要做的事情。第一部分是分辨率的输入之一。最后一部分是合并的输出。

$ git rerere diff
--- a/hello.rb
+++ b/hello.rb
@@ -1,11 +1,11 @@
 #! /usr/bin/env ruby
 def hello
-<<<<<<<
-  puts 'hello mundo'
-=======
+<<<<<<< HEAD
   puts 'hola world'
->>>>>>>
+=======
+  puts 'hello mundo'
+>>>>>>> i18n-world
 end

本节告诉您它正在考虑做什么。它想从一个文件中取出hello mundo,从另一个文件中取出hola世界,并将其替换为hello mundo。

$ git rerere diff
--- a/hello.rb
+++ b/hello.rb
@@ -1,11 +1,7 @@
 #! /usr/bin/env ruby
 def hello
-<<<<<<<
-  puts 'hello mundo'
-=======
-  puts 'hola world'
->>>>>>>
+  puts 'hola mundo'
 end

采用"hello mundo"和"hola world",并将该行替换为hola mundo

最新更新