我是新來的版本控制的世界,並剛剛開始使用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