git description --tags 未报告正确的标签



在我们的仓库上运行git describe --tags时,它不再报告其中一个分支上的最新标签,即使提交似乎在两个分支中。

有没有人知道这是如何发生的,以及我如何能够解决它,以便标签也可以在开发分支上使用?

$ git tag
...
2.7.1
2.7.2
2.7.3
2.7.4
$ git checkout develop
$ git describe --tags --abbrev=0
2.7.2
$ git rev-list -n 1 2.7.4
d700ec90cd7a82be076c1b69b0815a3dab4597ac
$ git rev-list -n 1 2.7.2
79c161b96541da2d039e0cef649044f57387fa8d
$ git cat-file -t 2.7.2
commit
$ git cat-file -t 2.7.4
commit
$ git merge master
Already up-to-date.
$ git branch --contains d700ec90cd7a82be076c1b69b0815a3dab4597ac
* develop
master
$ git describe --tags --abbrev=0
2.7.2
$ git log 2.7.4..HEAD
# shows the proper log even on develop (where the tag doesn't exist according to describe)
$ git checkout master
$ git describe --tags --abbrev=0
2.7.4

从开发分支:

$ git describe --tags --abbrev=0 --debug
searching to describe HEAD
lightweight      580 2.7.2
lightweight      613 2.7.1
lightweight      618 2.7.0
lightweight      791 2.6.0
lightweight     1134 2.5.2
lightweight     1210 2.5.1
lightweight     1345 2.5.0
lightweight     1464 2.4.4
lightweight     1597 2.7.4
lightweight     1597 2.7.3
traversed 1600 commits
more than 10 tags found; listed 10 most recent
gave up search at f3a739ef25d49556538e990c110df3f465e29fa3
2.7.2

从主分支:

$ git describe --tags --abbrev=0 --debug
2.7.4

从开发分支(截断(:

$ git log --graph --decorate --oneline --all --simplify-by-decoration
* c813804fd (HEAD -> develop, origin/develop, origin/HEAD) Merge pull request #3070
* d700ec90c (tag: 2.7.4, origin/master, master) Bump version: 2.7.3 → 2.7.4
* ce8e6b8a9 (tag: 2.7.3) Bump version: 2.7.2 → 2.7.3
* 79c161b96 (tag: 2.7.2) Bump version: 2.7.1 → 2.7.2
* 17aa75b5a (tag: 2.7.1) Bump version: 2.7.0 → 2.7.1
* e4b0d4c7e (tag: 2.7.0) Bump version: 2.6.0 → 2.7.0

git log --graph --decorate --oneline --all --simplify-by-decoration将显示存储库中内容的框架概述。 它的输出将是对您问题的最佳答案。

您最终使用的命令的 git 别名通常会让生活变得非常方便,研究如何

git config alias.lgdo '!f() { git log --graph --decorate --oneline "${@---all}"; }; f'

有效,你再也不会挨饿了1.


1好吧,好吧,也许吧。 但是别名和 shell 函数,以及别名中的 shell 函数,以及所有相关的方法,使事情变得更容易、更快,以便你可以 Git R Dun,都值得学习。

最新更新