[英]Git: find all tags, reachable from a commit
How can I list all tags , reachable from a given commit?如何列出可从给定提交访问的所有标签?
For all branches , it is git branch --all --merged <commit>
.对于所有分支,它是
git branch --all --merged <commit>
。 For most recent tag , it is git describe
.对于最近的标签,它是
git describe
。
Man page git-tag
suggests git tag -l --contains <commit> *
, but this command does not show any of the tags which I know are reachable.手册页
git-tag
建议git tag -l --contains <commit> *
,但此命令不显示我知道可以访问的任何标签。
use this script to print out all the tags that are in the given branch 使用此脚本打印出给定分支中的所有标记
git log --decorate=full --simplify-by-decoration --pretty=oneline HEAD | \
sed -r -e 's#^[^\(]*\(([^\)]*)\).*$#\1#' \
-e 's#,#\n#g' | \
grep 'tag:' | \
sed -r -e 's#[[:space:]]*tag:[[:space:]]*##'
The script is simply a 1 long line breaked down to fit in the post window. 该脚本只是一条长线,分解为适合后窗口。
git log // Print out the full ref name --decorate=full // Select all the commits that are referred by some branch or tag // // Basically its the data you are looking for // --simplify-by-decoration // print each commit as single line --pretty=oneline // start from the current commit HEAD // The rest of the script are unix command to print the results in a nice // way, extracting the tag from the output line generated by the // --decorate=full flag.
Man page git-tag suggests git tag -l --contains *, but this command does not show any of the tags which I know are reachable.
手册页 git-tag 建议使用 git tag -l --contains *,但此命令不显示我知道可以访问的任何标签。
git tag --contains
is for the opposite search. git tag --contains
用于相反的搜索。 It shows all tags containing the given commit.它显示包含给定提交的所有标签。 (This is the same behaviour as
git branch --contains
.) (这与
git branch --contains
行为相同。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.