git/push-tags

Push Tags to Remote

Push local tags to a remote repository so others can access them

git
push
tags
remote
release

Command

git push --tags

Explanation

The `git push --tags` command pushes all local tags to the remote repository. Tags are not automatically pushed when you push commits, so this command ensures that release tags and other important commit markers are available to collaborators. You can also push a single tag using `git push origin <tagname>`. This is especially important for versioning workflows where tags mark software releases. Without pushing tags, other users won’t see your tagged commits. Use caution with force pushes involving tags, as they can overwrite remote tags and cause confusion in shared repositories.

Common Use Cases

  • Publishing release tags for collaborators
  • Syncing local tags with remote repository
  • Making tagged versions available for CI/CD pipelines

Best Practices

  • Push tags after each release to ensure team access
  • Use `git push origin <tagname>` for selective pushing
  • Avoid force-pushing tags unless absolutely necessary

Common Mistakes to Avoid

  • Forgetting to push tags after creating them
  • Using `git push` without `--tags` and assuming tags are included
  • Overwriting remote tags with incorrect versions using force push

Troubleshooting

Problem: Tags not appearing on remote after pushing commits

Solution: Use `git push --tags` to explicitly push all tags.

Problem: Remote tag already exists with different commit

Solution: Delete the incorrect tag on remote (`git push origin --delete <tag>`) and re-push the correct one.

Examples

Push all local tags to the remote repository

git push --tags

Push a specific tag to the remote repository

git push origin v1.0

Delete a tag from the remote repository

git push origin --delete v1.0