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#^[^\(]*\(([^\)]*)\).*$##' \
-e 's#,#\n#g' | \
grep 'tag:' | \
sed -r -e 's#[[:space:]]*tag:[[:space:]]*##'
该脚本只是分解成 post window.
的 1 长行
解释:
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 --contains
用于反向搜索。它显示包含给定提交的所有标签。 (这与 git branch --contains
的行为相同。)
如何列出所有标签,可从给定的提交访问?
对于所有分支,是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#^[^\(]*\(([^\)]*)\).*$##' \
-e 's#,#\n#g' | \
grep 'tag:' | \
sed -r -e 's#[[:space:]]*tag:[[:space:]]*##'
该脚本只是分解成 post window.
的 1 长行 解释: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 --contains
用于反向搜索。它显示包含给定提交的所有标签。 (这与 git branch --contains
的行为相同。)