4.1 Overview
Hotfix branches are created specifically to address bugs. When bugs are fixed the Hotfix branch is merged into stage and master. This process results in a new release - a bug fix release. The assumption is that one branch is created for each bug and a release is generated for each bug. If you want to bundle bug fixes together for a big release this workflow would need to be modified. But for small projects this seems pretty good.
Branched from: master
Merge into: stage and master
Naming Convention: hotfix-x.y.z
4.2 Workflow
4.2.1 1) Create Hotfix Branch
Create a branch to deal with a bug off of master. Hotfix branches are created off of master because presumably the bug report is coming in from the production site.
git checkout -b hotfix-x.y.z master
Pay attention to the naming convension.
In naming this branch only bump .z
which is the incrementer used for bug fixes.
4.2.2 2) Append the version change to the readme.md file
Its good to do this now when you create the branch so you don't forget and also to others can see the version when working on the bug.
echo "Hotfix version x.y.z" >> readme.md
Add and commit changes
git commit -a -m "Released version x.y.z"
Push branch to Github so other developers can help fix the bug
git push origin hotfix-x.y.z
4.2.3 3) Fix the bug
magic code goes here
Commit the changes
git commit -a -m "Whatever hotfix action was taken"
and push changes to github if its an iterative process...
4.2.4 4) Merge Hotfix branch into master
switch to master branch
git checkout master
merge the fix to master
git merge --no-ff hotfix-x.y.z
push local master to origin master
git push origin master
Tell Git what version master currently is
git tag -a x.y.z
push that specific tag to master
git push origin <tag_name>
4.2.5 5) Merge Hotfix branch into stage
git checkout stage
merge the fix to stage
git merge --no-ff hotfix-x.y.z
delete the hotfix branch
git branch -d hotfix-x.y.z
Lastly push local stage to origin stage
git push origin stage
4.2.6 6) Delete the Hotfix branch
Delete locally
git branch -d release-x.y.z
Delete on Github if you didn't do all the work locally.
git push origin --delete <branch_name>