34

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?

clinton3141
  • 4,751
  • 3
  • 33
  • 46
kriysna
  • 6,118
  • 7
  • 30
  • 30

3 Answers3

24

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.

Peter van der Does
  • 14,018
  • 4
  • 38
  • 42
  • I'm not able to find git-flow version 1.9.0. Can you please help me to install it? – Anoop Thiruonam Apr 02 '16 at 03:33
  • Well, I had looked into this earlier. But it installs version 1.6.1 AVH Edition. I use Ubuntu. – Anoop Thiruonam Apr 03 '16 at 10:24
  • For Ubuntu version other than xenial, you need to do a manual install. From what you said you are using trusty. – Peter van der Does Apr 03 '16 at 21:50
  • Ok, I created a new PPA on Launchpad for git-flow AVH. https://launchpad.net/~pdoes/+archive/ubuntu/gitflow-avh It has the latest gitflow version for Ubuntu Precise, Trusty, Wily, and Xenial. I used the original Xenial package for backporting. – Peter van der Does Apr 05 '16 at 14:10
  • I've created a question for the same at http://stackoverflow.com/questions/36442801/how-to-install-git-flow-1-9-1-avh-in-ubuntu-14 Kindly paste your answer here so that it will help others who are looking for the same. Thank you. – Anoop Thiruonam Apr 06 '16 at 06:07
  • @PetervanderDoes: Could it be an idea to add the bugfix command to the wiki page there (https://github.com/petervanderdoes/gitflow-avh/wiki) ? – Terje Sandstrøm Jul 07 '16 at 19:07
13

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 3
    There is also a comment from the git-flow author saying exactly what you say: https://github.com/nvie/gitflow/issues/24 – hakunin Nov 13 '12 at 16:22
12

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 standard git-flow
  • start a new bugfix - git flow bugfix start <branch name>
lazaruslarue
  • 318
  • 2
  • 14
wired00
  • 13,930
  • 7
  • 70
  • 73