Git flow branching for fixing a bug

kriysna picture kriysna · Jun 26, 2012 · Viewed 20.3k times · Source

I have been using git flow for a while. I was searching for branching model for fixing issues and bugs found in the develop branch. I know we could use hotfix but it is for master branch, or quick bug fixes for the production.

Fixing a bug on development is not a feature. I could always reinitialize git flow and overwrite the default prefix branch to bug/. But it needed to reinitialize if I need to start new feature too. Is this a good practice or there is some technique to handle this?

Answer

Peter van der Does picture Peter van der Does · Jun 26, 2012

If the fix you need to apply is just a one commit fix I would just do it in develop without creating a branch, if it involves multiple commits you just use the git flow feature command. The software currently will do a git merge -ff when you finish a feature branch with only one commit, which in your logs will look the same as just a commit on develop.

If you would like to indicate in your log that this feature would be a bugfix you could just name the branch something like "bugfix-missing-parameter" or "issue-34-not-reading-file-properly"

I can see how the word feature could imply "something new" instead of "fixing" but that's just words. Should I create a new command for a fix, the code would look exactly the same as the code of git flow feature so I don't see any benefit in that.

Update November 19, 2015

Since Version 1.9.0 the gitflow AVH Edition has a bugfix command. It's the same thing as feature but the branch is prefix with bugfix instead of feature.