Adding tags to git repository

This is just a quick memo to remember how to add tags to repositories.

For exiting 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: 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.

Many years ago I have personally fallen in love with Semantic Versioning 2.0.0 and I am using it (three version components) whenever possible.

Also, for me a version is a version, so there is absolutely no need to prepend version number with v. Even if GitHub claims that this is a common practice to do so. For me, on contrary this is a stupidity, sorry.

Leave a Reply