Why Tags Aren’t Pulled Automatically
Tags are separate refs, not part of branch history. A standard `git pull` (fetch + merge) only brings tags that are reachable from the fetched branches. If a tag points to a commit that no branch references, it stays on the remote.
Verifying Remote Tags
Use `git ls-remote --tags origin` to see all tags stored on the remote. This command lists tag names and their SHA‑1 hashes, confirming the tag exists on the server.
git ls-remote --tags origin
Fetching Missing Tags
To bring a tag into your local repo, run one of the following:
git fetch --tags
# or fetch a single tag
git fetch origin tag v1.27.1:refs/tags/v1.27.1
Practical Commands
After fetching, list local tags with `git tag -l`. If you want every remote tag automatically, set:
git config --global remote.origin.tagopt --tags
Best Practices
Create annotated tags (`git tag -a v1.27.1 -m "Release 1.27.1"`) so they carry metadata. Push with `git push origin v1.27.1`. Regularly run `git fetch --tags` or enable automatic tag fetching to keep local refs in sync.
Takeaway: Run `git fetch --tags` or fetch the specific tag to sync remote tags.
People also ask
How do I list all tags on the remote?
Use `git ls-remote --tags origin` to display every tag stored on the remote repository.
Will a lightweight tag be fetched with `git fetch --tags`?
Yes, `git fetch --tags` retrieves both annotated and lightweight tags that exist on the remote.
Inspired by a public discussion on Stack Overflow. This article is an original explanation for learners.