簡體   English   中英

有沒有辦法得到一個HEAD〜 <number> 通過在git中提交哈希總和

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM