Git: find all tags accessible from commit

How can I list all tags reachable from a given commit?

For all branches of this git branch --all --merged <commit>. For the last tag, this git describe.

<page> git-tagsuggests git tag -l --contains <commit> *, but this command does not show any of the tags available to me.
+4
source share
1 answer

use this script to print all tags that are in this thread

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

A script is just 1 long line, folded to fit in a message box.

Explanation:
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.
+4
source

Source: https://habr.com/ru/post/1612707/


All Articles