我是版本控制领域的新手,刚刚开始使用 git。运行命令时有以下输出git log
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~
我理解为"Show me the difference between the latest commit and the previous commit"的命令,我会得到以下输出:
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~