How to do a Production Hotfix
Join the DZone community and get the full member experience.
Join For FreeSituation
It’s Thursday/Friday evening, the
daily version / master branch was deemed too risky to install, and you
decide to wait for Sunday/Monday with the deploy to production.
There’s a new critical bug found in production.
We do not want to install the bug on top of all the other changes, because of the risk factor.
What do we do?
Develop the fix on top of the production branch, in our local machine,
git push, and deploy the fix, without all the other changes.
How can I do this?
My example uses a Play Framework service, but that’s immaterial.
- gitk –all – review the situation
- Suppose the latest version deployed in prod is 1.2.3, and master has some commits after that.
- You checkout this version:
git checkout 1.2.3 - Create a new branch for this hotfix.
git checkout -b 1.2.3_hotfix1 - Fix the bug locally, and commit.
- Test it locally.
- git push
- On the production machine:
- git fetch (not pull!)
- sudo service play stop
- git checkout 1.2.3_hotfix1
- sudo service play start
- Test on production
- Merge the fix back to master:
- git checkout master
- git merge 1.2.3_hotfix1
- git push
- Clean up the local branch:
git branch -d 1.2.3_hotfix1
(Note: the branch will still be saved on origin, you’re not losing any information by deleting it locally)
Published at DZone with permission of Ron Gross, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments