Git:查找所有可从提交中到达的标记

ni65a41a  于 2023-08-01  发布在  Git
关注(0)|答案(3)|浏览(66)

如何列出从给定提交可到达的所有标签

所有分支git branch --all --merged <commit>most recent taggit describe

手册页git-tag建议使用git tag -l --contains <commit> *,但是这个命令没有显示任何我知道可以访问的标记。

xdnvmnnf

xdnvmnnf1#

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

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

字符串
脚本只是一个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.

yrwegjxp

yrwegjxp2#

手册页git-tag建议使用git tag -l --contains *,但是这个命令没有显示任何我知道可以访问的标签。
git tag --contains用于相反的搜索。它显示包含给定提交的所有标记。(这与git branch --contains的行为相同。)

42fyovps

42fyovps3#

Git现在已经支持了这个功能,但是(也许并不奇怪)是以一种反直觉的方式:

git tag --merged [revision]

字符串
行为(以及名称的基本原理)comes fromgit branch --merged:你要求查看所有已经合并到指定版本中的项目。这种措辞对分支有意义,但不幸的是对标记没有意义。
https://stackoverflow.com/a/41175150/1858225

相关问题