I'd like to see which tags I have locally that aren't available on a particular remote. How can I do this? I know I can do git push --tags
to push all of them. However, if there are some tags that I don't want pushed, how to I make sure I haven't missed some?
List Local Git Tags. In order to list Git tags, you have to use the “git tag” command with no arguments. You can also execute “git tag” with the “-n” option in order to have an extensive description of your tag list. Optionally, you can choose to specify a tag pattern with the “-l” option followed by the tag pattern.
To fetch tags from your remote repository, use “git fetch” with the “–all” and the “–tags” options. Let's say for example that you have a tag named “v1. 0” that you want to check out in a branch named “release”. Using this command, you have successfully checked out the “v1.
Use Git to delete a Git tag To delete the Git tag from the local repo, run the git tag -d tag-name command where tag-name is the name of the Git tag you want to delete.
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.
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