Push a tag to git repo using CLI
Adding a tag
To add a tag to a git repository, run the following command:
git tag <tagname>
Adding a tag with a message attached to it
If you want to add a message to the tag
git tag -a <tagname> -m '<message>'
I suggest you to add a message for every tag. Because
git push --follow-tags
will push the tags that have annotations
only.
Push tags to github repo
To push a single tag to a git repo, run the following command:
git push origin <tag_name>
To push all tags to a git repo, run the following command:
git push --follow-tags
It pushes both
- [x] commits, and
- [x] tags - annotated and reachable (an ancestor) from the pushed commits
It doesn't push
- [ ] annotated tags on unrelated branches
- [ ] lightweight tags that are not annotated
Use the command git config --global push.followTags true
to turn
on this flag by default.
Another way to push all tags to remote repo is to run
git push --tags
. This is not recommended because
it pushes all tags including lightweight tags that are not annotated and tags
on unrelated branches.
Last Updated on
Comments