git show可以用於顯示提交日誌的相關信息(以不同格式或信息量的多少)。
1.git show
默認顯示的是HEAD,如想顯示某個提交信息,那麼在git show後帶上某個提交的hash值即可
$ git show ff3234f
2.git show --pretty[=<format>]|--format=<format>:
以某種格式來輸出提交日誌信息(注意:並不會改變差異格式)
$ git show --pretty=format:"%h %s" //以hash值和提交備註的格式輸出提交日誌信息
$ git show --format="%h %s" //與上方命令等價
$ git show --format=oneline //以一行的格式輸出提交日誌(包括完整的hash值和提交備註)
45a80aee40c64ad2fc7590e51975b608c09b4796 abc
$ git show --format=short //以短格式輸出提交日誌(包括hash值、作者、提交備註)
commit 45a80aee40c64ad2fc7590e51975b608c09b4796
Author: Jony <[email protected]>
abc
$ git show --pretty=medium //git show默認以medium格式顯示
commit 45a80aee40c64ad2fc7590e51975b608c09b4796
Author: Jony <[email protected]>
Date: Sun Nov 17 11:58:46 2019 +0800
abc
$ git show --format=full //以全格式輸出提交日誌
commit 45a80aee40c64ad2fc7590e51975b608c09b4796
Author: Jony <[email protected]>
Commit: Jony <[email protected]>
abc
$ git show --format=fuller //比滿格式更詳細的輸出提交日誌
commit 45a80aee40c64ad2fc7590e51975b608c09b4796
Author: Jony <[email protected]>
AuthorDate: Sun Nov 17 11:58:46 2019 +0800
Commit: Jony <[email protected]>
CommitDate: Sun Nov 17 11:58:46 2019 +0800
abc
$ git show --format=email //以email格式輸出提交日誌
From 45a80aee40c64ad2fc7590e51975b608c09b4796 Mon Sep 17 00:00:00 2001
From: Jony <[email protected]>
Date: Sun, 17 Nov 2019 11:58:46 +0800
Subject: [PATCH] abc
$ git show --format=raw //以原始格式輸出提交日誌
commit 45a80aee40c64ad2fc7590e51975b608c09b4796
tree b3f72990611d77de8d0e05dff8db8e3b6b963cdf
parent 70a5ce6091aa59d5e3909af117340805214f10ee
author Jony <[email protected]> 1473963126 +0800
committer Jony <[email protected]> 1473963126 +0800
abc
3.git show --abbrev-commit --abbrev=<n>
:使提交的hash值以n位來顯示
$ git show --abbrev-commit --abbrev=8 //提交的hash值以8位來顯示
commit 45a80aeb
Author: JonyTC <[email protected]>
Date: Sun Nov 17 11:58:46 2019 +0800
sfdf
注:本文爲Jony原創,未經許可不得在任何平臺轉載。如需轉載,與作者聯繫~
歡迎加入linux交流羣:734638086,分享工作經驗。
關注微信公衆號:技術訓練營(微信ID:TechBootcamp),獲取更多資訊~
微信掃一掃,發現更精彩。