How to list unpushed Git tags How to list unpushed Git tags git git

How to list unpushed Git tags


You can use the following to see the tags that exist locally but not in the specified remote:

git show-ref --tags | grep -v -F "$(git ls-remote --tags <remote name> | grep -v '\^{}' | cut -f 2)"

Note that git ls-remote shows both the annotated tag and the commit it points to with ^{}, so we need to remove the duplicates.

An alternative is to use the --dry-run/-n flags to git push:

git push --tags --dry-run

This will show what changes would have been pushed, but won't actually make these changes.


For the record, I am using a variant of this with the 'comm' command:

comm -23 <(git show-ref --tags | cut -d ' ' -f 2) <(git ls-remote --tags origin | cut -f 2)

I am using it as a git alias in .gitconfig, with proper bash quoting like this:

[alias]    unpushed-tags = "!bash -c \"comm -23 <(git show-ref --tags | cut -d ' ' -f 2) <(git ls-remote --tags origin | cut -f 2)\""