我有一个使用的脚本
git describe --tags --abbrev=0
为了确定 repo 上的最新标签。到目前为止,一切都很好。
但是如果我必须在同一个提交上添加标签,该命令会为我提供所述提交的第一个可用标签,而不是最新的。
这是一个简单的例子
~ $ mkdir test_dir
~ $ cd test_dir/
test_dir $ git init
Initialized empty Git repository in /home/amaurin/test_dir/.git/
test_dir (unborn) $ touch coucou
test_dir (unborn ✱1) $ git add coucou
test_dir (unborn ✚1) $ git commit -m "Initial Commit"
[master (root-commit) 6972f53] Initial Commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 coucou
test_dir (master ✔) $ git tag 1
test_dir (master ✔) $ git describe --tags --abbrev=0
1
test_dir (master ✔) $ git tag 2
test_dir (master ✔) $ git tag
1
2
test_dir (master ✔) $ git describe --tags --abbrev=0
1
在最后一次通话中,我期待的是 2,而不是 1,我不明白为什么......
有趣的是,我在 GIT 更新日志中看到类似的问题已经得到修复:
- “git describe”没有正确地打破指向同一个提交的标签;通过现在注意
标记日期,首选较新的。
https://www.kernel.org/pub/software/scm/git/docs/RelNotes-1.7.1.1.txt 有趣的是我有一个最新版本的 git
$ git --version
git version 2.2.1
请帮忙 :'-(
叹……叹……