[英]Is there a way to get a HEAD~<number> by commit hash sum in git
我有一個特別的提交哈希。 有沒有一種方法可以獲取此提交的HEAD的“數字”?
如果您臨時標記HEAD
則可以使用git describe --contains
獲取此信息。
# make a temporary tag because describe will only use tags
git tag tmpXYZ
git describe --contains --match tmpXYZ <commit-id>
# prints something like tmpXYZ~21, or perhaps something more complex
# remove temp tag
git tag -d tmpXYZ
請注意,如果您正在查看的提交不在HEAD
的直接第一父路徑上,則可能會得到更復雜的描述,例如(實際示例): tmpXYZ~64^2~14^2~1
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.