How to create a hotfix

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:

  1. Get the latest changes from your remote
    • git fetch
  2. Checkout the version you would like to patch with the hotfix (ex.: “v1.2.3”)
    • git checkout VERSION
  3. Create the hotfix branch for the related version. It should follow the semver convention (ex.: “v1.2.3-1”)
    • git checkout -b hotfix/HOTFIXVERSION
  4. Do your modifications, cherry-pick, apply patches, etc.
  5. Commit your changes
    • git add .
    • git commit -m “fix: The commit message comes here”
  6. Push them to the remote
    • git push -u origin hotfix/HOTFIXVERSION
  7. Tag the hotfix version and push
    • git tag HOTFIXVERSION
    • git push origin HOTFIXVERSION

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.