Git flow for hotfix

Mohamed Kashif
2 min readSep 6, 2021

--

There are a lot of flows in git to handle hotfix but usually there is specific flows which widely used among most teams, in this little article I will go through one of my favourites flows to handle hotfix which I used in most of teams I joined.

You can use git client instead of terminal to do hot fix, I recommend using of GitKraken

Step 1:

Check you branches status by the following commands, the * specify the branch you stand at.

$ git branche
develop
* master

Step 2

Create a hotfix branch from master that will contain your fix

$ git checkout -b hotfix/1.0.1 origin/master
Branch hotfix/1.0.1 set up to track remote branch master from origin.
Switched to a new branch 'hotfix/1.0.1'

Step 3

Push the hot fix branch to the remote git after finishing your changes

$ git push origin hotfix/1.0.1

Step 4

Check out to master branch and run the merge command

$ git checkout master
$ git merge --no-ff hotfix/1.0.1

Step 5

Create a tag for the hotfix

$ git tag -a 1.0.1 -m 'Create hotfix tag 1.0.1'

Step 6

Verify that tag is created

$ git tag

Step 7

Push master to remote repo then push tag

$ git push origin master
$ git push origin --tags

Step 8

Check out to develop to merge the fixed code to develop

$ git checkout develop
$ git merge hotfix/1.0.1
$ git push origin develop

Step 9

Remove hotfix branch from local then remote repo

$ git branch -D hotfix/1.0.1
$ git push origin :hotfix/1.0.1

--

--