我是新来的版本控制的世界,并刚刚开始使用git。我有以下的输出,当我运行命令git log
为什么git diff会根据提交修订版产生不同的结果?
commit 3b33318e20a64f4395bba416fe60f50f9e0002d1
Author: pm
Date: Thu Jan 24 08:42:24 2013 +1300
added fourth line to test1
commit 37f2ce409cdc971958add1fcf6585064f5c0d61d
Author: pm
Date: Thu Jan 24 08:41:24 2013 +1300
first commit
我明白git log
显示最新提交随后一次提交。现在,如果我运行命令git diff HEAD HEAD~
我的理解是“给我的最新提交和以前提交的差别”,我得到下面的输出:
diff --git a/test1 b/test1
index c6f02c2..e41a5e4 100644
--- a/test1
+++ b/test1
@@ -1,4 +1,3 @@
This is a test document
This is the second line in the document
And the third
-Added a fourth line
这显示了我添加的减号当我修改文件test1时出现一个新行然而,如果我运行命令git diff HEAD~ HEAD
,我知道它是“显示第二个最后提交和最新提交”之间的区别,它会显示以下输出:
diff --git a/test1 b/test1
index e41a5e4..c6f02c2 100644
--- a/test1
+++ b/test1
@@ -1,3 +1,4 @@
This is a test document
This is the second line in the document
And the third
+Added a fourth line
它显示我添加了带加号的第四行。
文件是如何比较的?我会想你的比较文件的方式是“比较最新的和以前的”即git diff HEAD HEAD~
逻辑上似乎'差异ab'≠'差异ba',所以我不明白你的问题... – CharlesB
@CharlesB - 谢谢,但怎么也比较一般做即先前的/新的或新的/以前? – PeanutsMonkey