Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git flow branching for fixing a bug

Tags:

git

git-flow

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?

like image 582
kriysna Avatar asked Jun 26 '12 06:06

kriysna


People also ask

Which one is best branching Git workflow to follow?

GitHub Flow Branch Strategy The GitHub flow branching strategy is a relatively simple workflow that allows smaller teams, or web applications/products that don't require supporting multiple versions, to expedite their work. In GitHub flow, the main branch contains your production-ready code.

What is the best branching strategy in git?

Build your strategy from these three concepts: Use feature branches for all new features and bug fixes. Merge feature branches into the main branch using pull requests. Keep a high quality, up-to-date main branch.

What is bugfix branch in git?

The topic branches created off the release branch to deal with issues are known as bugfix branches. Gitflow bugfix branches only interact with the release branch. The Gitflow bugfix branch should not be confused with the hotfix branch which interacts exclusively with the master branch.


2 Answers

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.

like image 82
Peter van der Does Avatar answered Sep 19 '22 04:09

Peter van der Does


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.

like image 35
VonC Avatar answered Sep 21 '22 04:09

VonC