繁体   English   中英

Git:查找所有标签,可从提交访问

[英]Git: find all tags, reachable from a commit

如何列出可从给定提交访问的所有标签

对于所有分支,它是git branch --all --merged <commit> 对于最近的标签,它是git describe

手册页git-tag建议git tag -l --contains <commit> * ,但此命令不显示我知道可以访问的任何标签。

使用此脚本打印出给定分支中的所有标记

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:]]*##'

该脚本只是一条长线,分解为适合后窗口。

说明:
 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. 

手册页 git-tag 建议使用 git tag -l --contains *,但此命令不显示我知道可以访问的任何标签。

git tag --contains用于相反的搜索。 它显示包含给定提交的所有标签。 (这与git branch --contains行为相同。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM