git log只显示一个提交ID [英] git log show one commit id only
问题描述
我使用命令
p> git log -3 --pretty = format:%h
结果是
ffbef87
cf0e073
1c76c5d
我只想显示 1c76c5d 。您可以使用 git show
git-scm.com/book/en/v2/Git-Tools-Revision-Selection#Ancestry-Referencesrel =noreferrer>引用第三个父项从你当前的提交(即第二个祖先< C $ C> HEAD )。此外, git show
接受与 git log
相同的格式字符串:
git show head〜2 --pretty = format:%h--no-patch
更新( 2016-12-01 )
更好的方法是使用 rev-parse
使用 plumbing命令 > -
选项输出缩写(7个字符)提交ID:
git rev- parse --short head〜2
或者您也可以指定提交ID的确切长度:
git rev-parse --short = 4 head〜2
I need some help. It is possible to only show one commit id? Since git log -3 show the log from 1 - 3, I just want to show only 3. What possible command will match for it?
I use the command
git log -3 --pretty=format:"%h"
the result is
ffbef87
cf0e073
1c76c5d
I only want to display the 1c76c5d only.
You can use git show
referencing the third parent from your current commit (i.e. the second ancestor from HEAD
). Also, git show
accepts the same format string as git log
:
git show head~2 --pretty=format:"%h" --no-patch
Update (2016-12-01)
An even better way would be to use the rev-parse
plumbing command with the --short
option to output the abbreviated (7 characters) commit ID:
git rev-parse --short head~2
Or you could also specify the exact length of the commit ID:
git rev-parse --short=4 head~2
这篇关于git log只显示一个提交ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!