gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 13:37:42 24 4
gpt4 key购买 nike

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

对于所有分支机构,它是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:]]*##'

该脚本只是一个 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.

关于Git:查找所有标签,可从提交中访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33275853/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com