Adding tags to git repository
This is just a quick memo to remember how to add tags to repositories.
For any exiting non-latest commit:
- List all commits:
git log --pretty=oneline
- Pick the one you wish to tag (first seven letters of the has are enough), i.e.:
32c274c
- Add a tag:
git tag -a 0.1.0 32c274c -m "First version before general refactor"
For latest commit, the same, but without providing commit hash:
git tag -a 1.4.5 -m "My version 1.4.5"
Tags are always added to local repository and never pushed to remote by default. You have to explicitly tell git to do so. For example, by executing git push --tags
.
More info in Git Basics – Tagging and Managing releases in a repository.
Read More “Adding tags to git repository”