我在存储库中有一堆没有注释的标记,我想弄清楚它们指向哪个提交。是否有一个命令只列出标签和它们的提交sha ?检查标签和查看头部似乎有点太费力对我来说。
更新
在检查完响应后,我意识到我实际上想要的只是查看标记之前的历史记录,对于这一点git log <tagname>就足够了。
标记为answer的答案对于获取标记及其提交的列表很有用,这就是我所要求的。通过一点shell hack,我相信可以将这些转换为SHA+Commit消息。
我在存储库中有一堆没有注释的标记,我想弄清楚它们指向哪个提交。是否有一个命令只列出标签和它们的提交sha ?检查标签和查看头部似乎有点太费力对我来说。
更新
在检查完响应后,我意识到我实际上想要的只是查看标记之前的历史记录,对于这一点git log <tagname>就足够了。
标记为answer的答案对于获取标记及其提交的列表很有用,这就是我所要求的。通过一点shell hack,我相信可以将这些转换为SHA+Commit消息。
当前回答
如果您想查看标记SOMETAG(标记器,日期等)的详细信息,它所指向的提交的哈希值和一些关于提交的信息,但没有完整的差异,请尝试
git show --name-status SOMETAG
示例输出:
tag SOMETAG
Tagger: ....
Date: Thu Jan 26 17:40:53 2017 +0100
.... tag message .......
commit 9f00ce27c924c7e972e96be7392918b826a3fad9
Author: .............
Date: Thu Jan 26 17:38:35 2017 +0100
.... commit message .......
..... list of changed files with their change-status (like git log --name-status) .....
其他回答
一种方法是使用git rev-list。下面将输出标签所指向的提交:
$ git rev-list -n 1 $TAG
注释标签和Unannotated标签都适用
您可以在~/中添加它作为别名。如果你经常使用Gitconfig:
[alias]
tagcommit = rev-list -n 1
然后用:
$ git tagcommit $TAG
可能的陷阱:如果您有一个本地签出或具有相同标记名称的分支,这个解决方案可能会让您“警告:refname 'myTag'是不明确的”。在这种情况下,试着增加特异性,例如:
$ git rev-list -n 1 tags/$TAG
尽管这已经很老了,但我想指出我刚刚发现的一个很酷的功能,用于列出带有提交的标记:
git log --decorate=full
它将显示在提交处结束/开始的分支,以及提交的标记。
我也想知道正确的方法,但你总是可以窥探到:
$ cat .git/packed-refs
or:
$ cat .git/refs/tags/*
Git revlist -no-walk [tag_name]
来自Igor Zevaka:
总结
由于大约有4个几乎同样可接受但不同的答案,我将总结所有不同的方法来皮肤标签。
git rev-list -1 $TAG (answer). git rev-list outputs the commits that lead up to the $TAG similar to git log but only showing the SHA1 of the commit. The -1 limits the output to the commit it points at. git show-ref --tags (answer) will show all tags (local and fetched from remote) and their SHA1s. git show-ref $TAG (answer) will show the tag and its path along with the SHA1. git rev-parse $TAG (answer) will show the SHA1 of an unannotated tag. git rev-parse --verify $TAG^{commit} (answer) will show a SHA1 of both annotated and unannotated tags. On Windows use git rev-parse --verify %TAG%^^^^{commit} (four hats). cat .git/refs/tags/* or cat .git/packed-refs (answer) depending on whether or not the tag is local or fetched from remote.