Git – In GitHub flow, is it OK to base feature branch on another feature branch

gitgitflowgithub

We use GitHub Flow in our project and most of the time, we open a new feature branch from master, do some work there, open a PR, review the code and merge back into master.

However, my current work depends on another issue that is being worked on in feature-branch-A. Is it kosher to create my branch from that other branch or is that against the spirit of GitHub Flow?

The alternative would be to base my branch on master and merge-in the changes from feature-branch-A (frequently).

Which option is preferred in GitHub flow?

Best Answer

Here is the workflow that I follow when I branch from a feature branch:

  1. Create feature-branch-B from feature-branch-A
  2. Work on feature-branch-B
  3. If more commits are added to feature-branch-A after branching, rebase feature-branch-B onto feature-branch-A
  4. Finish work on feature-branch-B and wait till feature-branch-A is merged into master.
  5. After feature-branch-A is merged into master, rebase feature-branch-B onto master
  6. Merge feature-branch-B into master

By following the above workflow it will appear that you branched from master after feature-branch-A was merged. You don't have to wait till feature-branch-A is merged to start work on feature-branch-B. Yet, you will get a clean history without any complicated trees.

Related Topic