Git flow branching for fixing a bug
Pergunta
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?
Solução
git-flow-avh
is what you want
For osx:
brew uninstall git-flow #remove your current
brew install git-flow-avh #add the update
Within project folder:
git init
- you should see amongst prompts -
Bugfix branches? [bugfix/]
which would not have been a prompt with standardgit-flow
- start a new bugfix -
git flow bugfix start <branch name>
Outras dicas
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.
The idea of fixing a bug on the development
branch, as opposed to git flow hotfix
(on master
) is that:
- you generally fix the bug on development
HEAD
(it is just another commit which fixes some issue introduced by other commits) - you do an hotfix on a specific version/tag of master ("
production
branch") in a dedicated branch, and you will or will not merge that hotfix back (if the hotfix is very specific to a certain version, and is no longer relevant in the subsequent releases, you won't merge it back at all)
So I don't think you need a dedicated branch / "git flow
" operation: just make a well identified commit and push it on top of the development
branch.