如何判断一个标签在Git中指向哪个提交? [英] How to tell which commit a tag points to in Git?
问题描述
我在存储库中有一堆unannotated标记,我想确定它们指向哪个提交。有没有一个命令可以列出标签和它们的提交SHA?检查出标签并查看HEAD对我来说似乎有点费力。
更新
我意识到在我回过头来看看我真正想要的只是查看引用标签的历史记录之后,对于其中的 git log< tagname>
就足够了。
标记为答案的答案对于获取标签及其提交列表很有用,这就是我所要求的。有了一些shell hackery,我相信可以将它们转换为SHA + Commit消息。
解决方案
这将与 git rev-list
。以下将输出一个标签指向的提交:
$ git rev-list -n 1 $ TAG
您可以将它作为别名添加到〜/ .gitconfig
如果你使用它很多:
[别名]
tagcommit = rev-list -n 1
然后调用它:
$ git tagcommit $ TAG
I have a bunch of unannotated tags in the repository and I want to work out which commit they point to. Is there a command that that will just list the tags and their commit SHAs? Checking out the tag and looking at the HEAD seems a bit too laborious to me.
Update
I realized after I went through the responses that what I actually wanted was to simply look at the history leading up to the tag, for which git log <tagname>
is sufficient.
The answer that is marked as answer is useful for getting a list of tags and their commits, which is what I asked. With a bit of shell hackery I'm sure it's possible to transform those into SHA+Commit message.
One way to do this would be with git rev-list
. The following will output the commit to which a tag points:
$ git rev-list -n 1 $TAG
You could add it as an alias in ~/.gitconfig
if you use it a lot:
[alias]
tagcommit = rev-list -n 1
And then call it with:
$ git tagcommit $TAG
这篇关于如何判断一个标签在Git中指向哪个提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!