所以,
如果我这样做:
git tag -a v4.2 -m 'my message'
然后我运行:
git show v4.2
我没有看到“我的消息”,而是看到了最后一次提交的消息。
我怎样才能看到该标签的消息?
从git show
文档中:
对于标签,它显示标签消息和引用的对象。
因此,您所描述的应该可以正常工作。这是一个完整的例子:
$ git init
Initialized empty Git repository in /Users/carl/Desktop/example/.git/
$ touch file
$ git add file
$ git commit -m "added a file"
[master (root-commit) 198fa55] added a file
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file
$ git tag -a sometag -m "tag message"
$ git show sometag
tag sometag
Tagger: Carl Norum <somebody@somewhere>
Date: Mon Jul 8 10:10:49 2013 -0700
tag message
commit 198fa55868770ab78786e704dbb290cbeefac011
Author: Carl Norum <somebody@somewhere>
Date: Mon Jul 8 10:10:42 2013 -0700
added a file
diff --git a/file b/file
new file mode 100644
index 0000000..e69de29
您需要将 -n 选项与“git -l”或“git tag”一起使用。这将显示所有标签及其消息(第一行):
git tag -n
-n 显示注释的可选行数,默认为一。从git 标签参考:
-n<数字>
<num> specifies how many lines from the annotation, if any, are printed when using -l. Implies --list. The default is not to print any annotation lines. If no number is given to -n, only the first line is printed. If the tag is not annotated, the commit message is displayed instead.