Simple git log <hash>
要求合并提交显示其父级的缩写哈希值:
$ git log -1 395f65d
commit 395f65d438b13fb1fded88a330dc06c3b0951046
Merge: 9901923 d28790d
...
git
根据编号输出父母:第一个(最左边)哈希值用于第一个父母,依此类推。
如果您只想要哈希值,则两个等效的选择是:
$ git log --pretty=%P -n 1 <commit>
$ git show -s --pretty=%P <commit>
git rev-list
还可以显示父级的哈希值,尽管它会首先列出提交的哈希值:
$ git rev-list --parents -n 1 <commit>
如果你想检查父母,你可以直接用克拉来指代他们<commit>^1
and <commit>^2
, e.g.:
git show <commit>^1
This does generalize; for an octopus merge you can refer to the nth parent as <commit>^n
. You can refer to all parents with <commit>^@
, though this doesn't work when a single commit is required. Additional suffixes can appear after the nth parent syntax (e.g. <commit>^2^
, <commit>^2^@
), whereas they cannot after ^@
(<commit>^@^
isn't valid). For more on this syntax, read the rev-parse http://schacon.github.com/git/git-rev-parse.html man page.