如何列出所有标记,可以从给定提交中找到?
对于所有分支,它是git branch --all --merged <commit>
。
对于最新标记,它为git describe
。
手册页git-tag
建议git tag -l --contains <commit> *
,但此命令不会显示我知道可以访问的任何标记。
答案 0 :(得分:4)
使用此脚本打印出给定分支中的所有标记
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.