If you follow the Semantic Versioning notation when delivering your code it’s important to know the way to create a hotfix when needed. Here are the basic steps to follow in order to achieve it:
- Get the latest changes from your remote
- git fetch
- Checkout the version you would like to patch with the hotfix (ex.: “v1.2.3”)
- git checkout VERSION
- Create the hotfix branch for the related version. It should follow the semver convention (ex.: “v1.2.3-1”)
- git checkout -b hotfix/HOTFIXVERSION
- Do your modifications, cherry-pick, apply patches, etc.
- Commit your changes
- git add .
- git commit -m “fix: The commit message comes here”
- Push them to the remote
- git push -u origin hotfix/HOTFIXVERSION
- Tag the hotfix version and push
- git tag HOTFIXVERSION
- git push origin HOTFIXVERSION