日常开发工作中,代码库是程序员关注最多的资源,不论是代码入库,版本发布,还是bug修复,都离不开代码库。代码库的每次提交变动,关系到版本的正常发布。
为了查看某次提交或者某个文件的改动记录,下面介绍几个命令。
查看某次提交的修改内容
$ git show commit-id
$ git show 6454f159e3642b361f8e
commit 6454f159e3642b361f8ea6afe22c3f264f768b9b
Author: lanyang<lanyang@gmail.com>
Date: Fri Oct 28 16:45:24 2016 +0800
206
diff --git a/3.txt b/3.txt
index 00750ed..f4540d5 100644
--- a/3.txt
+++ b/3.txt
@@ -1 +1,2 @@
3
+206
查看所有提交的修改内容
$ git log -p
查看最近两次提交修改的内容
$ git log -p -2
查看某个文件或目录的修改记录
$ git log -p < file name or directory name>
$ git log -p 1.txt
commit 29c23277f5e306c7514d393781d35e62efe82265
Author: lanyang<lanyang@gmail.com>
Date: Fri Oct 28 18:03:57 2016 +0800
commit not push now2
diff --git a/1.txt b/1.txt
index d77212f..cdc1ca1 100644
--- a/1.txt
+++ b/1.txt
@@ -5,3 +5,4 @@ helloworld
12222
hello
commit not push now1
+commit not push now2
commit 75a33de417f3fceb5b0af10f1f13460e6495f9d2
Author: lanyang<lanyang@gmail.com>
Date: Fri Oct 28 18:03:37 2016 +0800
commit not push now1
diff --git a/1.txt b/1.txt
index e37ce3c..d77212f 100644
--- a/1.txt
+++ b/1.txt
@@ -4,3 +4,4 @@ helloworld
21
12222
hello
+commit not push now1
小结:
本文主要介绍代码库提交记录及文件修改记录的查看方式。