How can I list all tags, reachable from a given commit?
For all branches, it is git branch --all --merged <commit>
.
For most recent tag, it is git describe
.
Man page git-tag
suggests git tag -l --contains <commit> *
, but this command does not show any of the tags which I know are reachable.
In order to find the latest Git tag available on your repository, you have to use the “git describe” command with the “–tags” option. This way, you will be presented with the tag that is associated with the latest commit of your current checked out branch.
Viewing tags On GitHub.com, navigate to the main page of the repository. To the right of the list of files, click Releases. At the top of the Releases page, click Tags.
Listing the available tags in Git is straightforward. Just type git tag (with optional -l or --list ). You can also search for tags that match a particular pattern. The command finds the most recent tag that is reachable from a commit.
Tags are not merged, commits (tagged or not) are.
use this script to print out all the tags that are in the given branch
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:]]*##'
The script is simply a 1 long line breaked down to fit in the post window.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With