Is there an easy way to determine which tags I have in my local repo that are out of sync with the remote? By out of sync I mean that the exact same tag name points to a different commit on my local vs the remote. Two ways I can think of to end up in this situation might be:
- Someone (or something) moved a tag that I previously fetched. Perhaps it was deleted and recreated, or it was force created when it already existed. (I realize this is frowned upon but that doesn't stop it from happening.)
- I created a tag locally, and then someone (or something) created the same tag name on a different commit and pushed it out before I did.
Another way to word this question might be:
Which of my local tags will be updated if I were to run the following command:
git fetch origin --tags --force
Update: based on the answer, this one liner should work in Git Bash:
diff <(git for-each-ref refs/tags --format="%(objectname)%09%(refname)") <(git ls-remote --tags | grep -v "\^{}")
Explanation: The command lists all your local tags, and formats it so that it uses the same format as ls-remote. (%09 is a tab character.) Then diff the two outputs.