3、查看提交歷史
我們可以使用git log這個(gè)命令來查看提交的歷史記錄耿导。
默認(rèn)不用任何參數(shù)声怔,git log 會(huì)按提交時(shí)間列出所有的更新,最近的更新排在最上面舱呻。這個(gè)命令會(huì)列出每個(gè)提交的 SHA-1 校驗(yàn)和醋火、作者的名字和電子郵件地址、提交時(shí)間以及提交說明箱吕。
commit 6597abf6bb3617c2cbaad12cf1749d9771464ecd
Author: wendong <28152082@qq.com>
Date: Tue Nov 28 12:03:00 2017 +0800
git mv test
commit 2b1583efcc6e18d0f80946f88d416b140b01367a
Author: wendong <28152082@qq.com>
Date: Tue Nov 28 12:01:17 2017 +0800
delete Hello.txt
commit 9ccca93a00bd91a4883595b2f44a416ffb5ede9e
Author: wendong <28152082@qq.com>
Date: Tue Nov 28 12:00:32 2017 +0800
mv test
commit 3a2db18768b228b3af6fa878e36544d15e35cfa4
Author: wendong <28152082@qq.com>
Date: Tue Nov 28 11:44:28 2017 +0800
rm test finish
…………
常用的選項(xiàng) -p芥驳,用來顯示每次提交的內(nèi)容差異。 也可以加上 -2 來僅顯示最近兩次提交:
commit 6597abf6bb3617c2cbaad12cf1749d9771464ecd
Author: wendong <28152082@qq.com>
Date: Tue Nov 28 12:03:00 2017 +0800
git mv test
diff --git a/Helloword.txt b/Hello.txt
similarity index 100%
rename from Helloword.txt
rename to Hello.txt
commit 2b1583efcc6e18d0f80946f88d416b140b01367a
Author: wendong <28152082@qq.com>
Date: Tue Nov 28 12:01:17 2017 +0800
delete Hello.txt
diff --git a/Hello.txt b/Hello.txt
deleted file mode 100644
index 709f846..0000000
--- a/Hello.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Hello world
-first modify
-second modify
-three modify
--stat 選項(xiàng)在每次提交的下面列出所有被修改過的文件殖氏、有多少文件被修改了以及被修改過的文件的哪些行被移除或是添加了晚树。 在每次提交的最后還有一個(gè)總結(jié)姻采。
commit 6597abf6bb3617c2cbaad12cf1749d9771464ecd
Author: wendong <28152082@qq.com>
Date: Tue Nov 28 12:03:00 2017 +0800
git mv test
Helloword.txt => Hello.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
commit 2b1583efcc6e18d0f80946f88d416b140b01367a
Author: wendong <28152082@qq.com>
Date: Tue Nov 28 12:01:17 2017 +0800
delete Hello.txt
Hello.txt | 4 ----
1 file changed, 4 deletions(-)
另外一個(gè)常用的選項(xiàng)是 --pretty雅采。 這個(gè)選項(xiàng)可以指定使用不同于默認(rèn)格式的方式展示提交歷史。 這個(gè)選項(xiàng)有一些內(nèi)建的子選項(xiàng)供你使用慨亲。 比如用 oneline 將每個(gè)提交放在一行顯示婚瓜,查看的提交數(shù)很大時(shí)非常有用。 另外還有 short刑棵,full 和 fuller 可以用巴刻,展示的信息或多或少有些不同,
6597abf6bb3617c2cbaad12cf1749d9771464ecd git mv test
2b1583efcc6e18d0f80946f88d416b140b01367a delete Hello.txt
9ccca93a00bd91a4883595b2f44a416ffb5ede9e mv test
3a2db18768b228b3af6fa878e36544d15e35cfa4 rm test finish
a80c6a946c0968edcbe3b9826629112b147a84e2 rm test
4794019de33bc2bfcea823ded27f80e98230e114 jump git add submit
b79795b531900217191da0db8b36ee220c074ad4 tree submit
a306d944c27e569f8003a82f7e251159cb61db33 second submit
5e874cc11b31065c65d4fd4ed7e6a275dca524d5 first submit
[root@node1 git-test]# git log --pretty=oneline -2
6597abf6bb3617c2cbaad12cf1749d9771464ecd git mv test
2b1583efcc6e18d0f80946f88d416b140b01367a delete Hello.txt
[root@node1 git-test]# git log --pretty=short -2
commit 6597abf6bb3617c2cbaad12cf1749d9771464ecd
Author: wendong <28152082@qq.com>
git mv test
commit 2b1583efcc6e18d0f80946f88d416b140b01367a
Author: wendong <28152082@qq.com>
delete Hello.txt
[root@node1 git-test]# git log --pretty=full -2
commit 6597abf6bb3617c2cbaad12cf1749d9771464ecd
Author: wendong <28152082@qq.com>
Commit: wendong <28152082@qq.com>
git mv test
commit 2b1583efcc6e18d0f80946f88d416b140b01367a
Author: wendong <28152082@qq.com>
Commit: wendong <28152082@qq.com>
delete Hello.txt
format蛉签,可以定制要顯示的記錄格式胡陪。
6597abf - wendong, 4 hours ago : git mv test
2b1583e - wendong, 4 hours ago : delete Hello.txt
9ccca93 - wendong, 4 hours ago : mv test
3a2db18 - wendong, 4 hours ago : rm test finish
a80c6a9 - wendong, 4 hours ago : rm test
4794019 - wendong, 5 hours ago : jump git add submit
b79795b - wendong, 5 hours ago : tree submit
a306d94 - wendong, 6 hours ago : second submit
5e874cc - wendong, 7 hours ago : first submit
git log --pretty=format 常用的選項(xiàng) 列出了常用的格式占位符寫法及其代表的意義
git log 的常用選項(xiàng)
限制輸入長度的選項(xiàng):