Example Git branching workflow
You will need to create a branching strategy that works best for your team, of course. But here is a quick example of how to follow a branching strategy workflow involving two types of branches: a develop/integration branch and a feature/topic branch.
Say you are working on a new feature when somebody finds a bug in the production, and you must fix that bug parallel to working on the new feature.
Before starting on the bug fix, you create a new branch off of the develop branch. This new branch isolates the bug fix from the new feature you were working on.
When ready to release the bug fix, you merge the bug fix feature branch into the develop branch.
Then you switch back to your original feature branch and continue working on the new feature.
On the feature branch, you notice that commit “X,” the bug fix commit, is needed to continue implementing the new feature. In other words, you have to synchronize your current branch with the changes on the develop branch.
There are two options to go about doing this: the first is to merge the develop branch that includes commit “X” with the current branch; the second option is to rebase the current branch to the develop branch that includes commit “X.”
For this example, you use the rebase approach.
Once you have “X” in your current working tree, you can begin safely working on the new feature again.