Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bug fixes in a feature branch

We're using a A successful Git branching model by Vincent Driessen for our branching model. All's fine but I haven't really seen a particular issue brought up.

From what I've understood, when a new feature is required, you branch of the development and create a new feature branch. You would work on this and when you're done, you would merge this branch into the the development branch.

What if a developer makes a feature and then merges that feature back to development only to be found out that there's some bugs in the feature code. Where should this be fixed? Should a new fix/bugfix branch be started from development and the code be fixed there? I can't see another way.

How should one go about this?

Thanks

like image 616
Mridang Agarwalla Avatar asked Aug 30 '11 05:08

Mridang Agarwalla


People also ask

What is bug fix branch?

There's no such thing as “the” bugfix branch. It's common practice for a developer to create a branch whenever they're working on anything that they expect to result in a commit. That might be developing a new feature (this is often called a “feature branch”) or fixing a bug (a “bugfix branch”).

What is bug fix 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.

What is the difference between hotfix and bugfix?

Bugfixes generally describe issues that are found and resolved during production or testing phases or even after deployment as part of the normal release cycle of a product. Hotfixes are applied only after the product has been released and is live.


1 Answers

Remember that a model is just a model - it's about giving you a structure that makes you more efficient, not blindly following a set of rules. That means that you should feel free to tweak things and figure out what works in your situation, because it may not work in every situation.

I think you have a choice in this situation:

  1. Roll back the merge and continue work on the feature branch until it is ready
  2. Start a new branch to fix the bug.

Which one you choose depends on factors like:

  • Can your customers see the bug? Make a bugfix or hotfix branch.
  • Is the bug really bad and stop other progress on the development branch? Roll back the change.
  • Is it only a minor issue with minimal external impact? Simply continue work on the feature branch and merge again when ready.

The difference between a feature branch and bugfix branch isn't important from Git's point of view. It only matters if you use those labels for internal documentation or other auditing purposes (e.g. to keep track of what is visible to external users).

Resist the temptation to work straight off the development branch even if you think the bugfix will be very quick - nothing is ever quite as simple as it seems, and you will give yourself a headache later if anything goes wrong.

Rough visual representation of your choices:

State machine diagram of choices

like image 53
Brian L Avatar answered Oct 25 '22 12:10

Brian L