Welcome to this comprehensive guide on Semantic Versioning with Tags using Git! This tutorial is designed for both beginners and intermediates, so let's get started. 📝
Semantic Versioning (SemVer) is a standard way to format the version numbers for your projects. It helps maintain compatibility as your project evolves, making it easier for developers to understand changes and decide whether to upgrade.
A SemVer version consists of three parts: MAJOR.MINOR.PATCH. Each part represents a different type of change:
In Git, we use tags to mark specific points in our project's history. This is particularly useful for SemVer, as we can associate a tag with each release.
To create a tag, follow these steps:
$ git tag v1.0.0 # Create a tag with the name v1.0.0
$ git push origin v1.0.0 # Push the tag to the remote repositoryTo see all the tags, use the following command:
$ git tagNow, let's combine SemVer and Git workflow. We'll use the GitFlow branching model for this example.
Let's consider a simple project with a version 0.1.0. We'll create a new feature (fix a bug) and then release it.
$ git checkout -b fix-bug$ git add .
$ git commit -m "Fixed a bug related to login"$ git checkout -b release/v1.0.1
$ git merge fix-bug$ git tag v1.0.1
$ git push origin v1.0.1$ git checkout develop
$ git merge release/v1.0.1
$ git push origin develop
$ git checkout master
$ git merge release/v1.0.1
$ git push origin masterWhat does the `MAJOR` part in SemVer represent?
Happy learning, and remember, practice makes perfect! 🤓