When you want to push a local Git tag to a remote repository, you can use the git push command to accomplish this. There are two main scenarios: pushing a single tag or pushing multiple tags. Below I will explain the operation methods for both.
Pushing a Single Tag to a Remote Repository
Assume you have already created a local tag v1.0. To push this tag to the remote repository, use the following command:
shellgit push origin v1.0
Here, origin is the default name for the remote repository, and v1.0 is the tag name you want to push. After executing this command, the tag v1.0 will be pushed to the remote repository.
Pushing All Newly Created Local Tags to a Remote Repository
If you want to push all newly created local tags to the remote repository at once, use:
shellgit push origin --tags
This command pushes all newly created local tags to the origin remote repository. Note that this command does not push deleted tags.
Example
Assume you are releasing a project version and create a tag named v2.0 to mark this release:
shellgit tag v2.0
After creating the tag, confirm it can be pushed to the remote repository for team sharing:
shellgit push origin v2.0
This way, your team members can obtain this specific project snapshot by pulling the remote tag.
If your team has adopted a versioning strategy and you have a series of tags (e.g., v1.1, v1.2, v2.0, etc.) that need to be pushed together, you might choose to push all tags:
shellgit push origin --tags
This is how to push Git tags to a remote repository.