list tags contained by a branch

git tag --merged <branch>

From the man page:

--[no-]merged <commit>

Only list tags whose tips are reachable, or not reachable if --no-merged is used, from the specified commit (HEAD if not specified).

I believe this option was added quite recently - it definitely wasn't available back when the original question was posed and the above answers suggested. Since this thread is still the first hit in Google for the question I figured I'd throw it in for anyone who scrolls down to the bottom looking for an answer that involves less typing than the accepted answer (and for my own reference when I forget this answer again next week).


This might be close to what you want:

git log --simplify-by-decoration --decorate --pretty=oneline "$committish" | fgrep 'tag: '

But, the more common situation is to just find the most recent tag:

git describe --tags --abbrev=0 "$committish"
  • --tags will search against lightweight tags, do not use it if you only want to consider annotated tags.
  • Do not use --abbrev=0 if you want to also see the usual “number of ‘commits on top’ and abbreviated hash” suffix (e.g. v1.7.0-17-g7e5eb8).

to list all tags reachable on the current 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:]]*##'

Tags:

Git