Bugs fixed in the feature branches

We use the successful Git branching model of Vincent Drissen for our branching model. Everything is fine, but I really did not see a particular problem.

From what I understood, when a new function is required, you introduce the development branch and create a new feature branch. You will work on it, and when you are done, you should merge this branch into the development branch.

What to do if the developer performs the function and then combines this function in development again to find some errors in the function code. Where should this be fixed? Should a new fix / bugfix from development be launched and the code will be fixed there? I do not see another way.

How can I do that?

thanks

+8
git git-branch branching-and-merging
source share
4 answers

Remember that a model is just a model — it gives you a structure that makes you more efficient, rather than blindly following a set of rules. This means that you must feel at ease to set things up and find out what works in your situation, because it may not work in any situation.

I think you have a choice in this situation:

  • Refuse merging and continue working on the property branch until it is ready.
  • Launch a new branch to fix the error.

Which choice you choose depends on factors such as:

  • Can your customers see a mistake? Create a hotfix or hotfix.
  • Is the error very bad and stops other progress in the development branch? Discard the changes.
  • Is this just a minor issue with minimal external impact? Just keep working on the feature branch and reconnect when you're ready.

The difference between an element branch and a bugfix branch is not important from a Git point of view. This only matters if you use these labels for internal documentation or other audit purposes (for example, to track what is visible to external users).

Resist the temptation to work directly from the development branch, even if you think that the error will be very quick - nothing seems as simple as it seems, and you will get a headache later if something goes wrong.

A rough visual representation of your options:

State machine diagram of choices

+9
source share

How about finding the commit that introduced the error and creating a new branch there ? With this approach:

  • There is no risk of creating broken links due to recovery operations
  • Just from the pedigree of the development branch, the function branch, and any other branch that may be affected, you can indicate where you should merge the patch branch after it is completed. This is true even if the “function” has merged several times with the “development” since the appearance of the error.
  • If you identify the commit that made the error and root from there, developers will be able to specify where they need to merge the bugfix branch, even if they are not familiar with the repo layout
  • You will have a branch that you can merge without fear of pulling in unrelated subsequent changes. For example, let's say someone is working on a “beta function,” which is a subdivision of a “function” that diverged shortly after an error occurred. They can easily pull in the bugfix branch, without worrying about pulling everything else that happened on the “function”.
  • This approach reduces the need for a cherry pick, which has the disadvantage that it changes the name of commits (thus undermining one of git's big advantages, which applies a unique name to everything.)
+3
source share

If this branch of the function is publicly available (that is, clicked on a remote repo that is being cloned / used by others), it is best to create a new branch and isolate debugging in the specified patch branch. (instead of trying to rebuild the feature branch at the top of the develop branch).

The idea is not to write intermediate debugging commits directly to the develop branch, but to write only the resulting commit, which will first correct the error introduced by the feature merge.

+1
source share

Just create a branch (or use the old, merged feature branch) and fix it there.

Using the old branch / creating a new branch is the same - you cannot name what after merging.

0
source share

All Articles