1

我正在阅读 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想要贡献的内容的否定。不过,这对我来说没有意义。第一部分是什么意思?

4

2 回答 2

2

回答

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

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

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

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

+任何以orno 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就是这个并且不使用组合的差异格式。

 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
  • 任何带有 a-的东西都是你开始的一部分
  • 任何带有 a+的内容都是您已解决的问题的一部分
  • 任何没有前缀的东西都是两者的一部分

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

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

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

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

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

于 2014-12-08T18:35:46.767 回答
0

从那个链接

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 world 并用 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

于 2014-12-08T17:36:08.623 回答