Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to work on a feature branch that relies on another unmerged feature branch?

Tags:

git

Here is my situation. I have featureBranchA in github pending a pull request which won't get merged until tomorrow or later. I started working on featureBranchB but I ran in to a snag. I need the changes made in featureBranchA in order to make featureBranchB work. I hate not being able to work due to waiting on someone else.

What I've done in the past is switch to featureBranchA and branch off that naming the branch featureBranchA/featureBranchB. When featureBranchA is merged I then submit a pull request to the newly renamed featureBranchB. This is not the best approach as I have to keep a list of branches that need pull requests and watch for when the "parent" branch was merged.

Another method I've used is branching featureBranchB off master and merging changes from featureBranchA in to it. This always messes up when I'm submitting a pull request though. The pull request for featureBranchB will have its commits AND featureBranchA commits even though featureBranchA has already been merged. I've also tried using rebase instead of merge but it messes up when it comes time to submit the pull request.

Any advice on this kind of work flow?

like image 492
Kylee Avatar asked Mar 11 '15 01:03

Kylee


1 Answers

Branching featureB off featureA is the best approach. Rather than monitoring when featureA is approved, submit the pull request when you're ready and note in the request that it depends on featureA. Reference the issue number in the pull request and Github will place notes itself. Something like "this depends on #123 being accepted".

If featureA is changed before being accepted, you (or the person accepting the pull request) should merge or rebase with featureA prior to merging featureB.

like image 138
Schwern Avatar answered Nov 15 '22 18:11

Schwern