How do you deal with dependent branches on github?

In general, it's good practice to make branches that are independent from other changes and in general kept to a diff of ~500 lines in order to keep pull requests (PRs) easy to review.

One issue though is how to deal with the scenario where you need to make more invasive changes?

Here's an example. I create branch A which has changes that affect the project significently, I propose it as a PR on github.

Now I need to work on my next feature branch B which needs to be built on top of branch A. But, if I create B from A then when I come to propose B it will contain the changes from A in the files diff.

So obvious answers to this are to not do this in the first place - but sometimes it's unavoidable. Secondly, you want the code pipeline to keep moving, so getting A reviewed and landed will allow B to be proposed. Sometimes you can't get code reviewed that quickly so you get blocked on proposing new changes. Or you propose it anyway and accept that the diff will contain "noise" from the branch dependency. (I've come to hate the latter).

Why dependent branches are useful

Breaking changes up into reviewable pieces can be very good for aiding code reviews. I'm guessing that in github they're avoided due to the fact github doesn't (afaik) have a good way to deal with them.

How launchpad solves this problem

This problem is something that doesn't exist on launchpad because you can propose a branch and mark a previous branch as a pre-requisite. This means the second branch only shows it's own changes in the diff.

In addition, the bzr-pipeline plugin (for bazaar) made dealing with dependent branches incredibly simple. You could have multiple dependent branches and if the first branch needed changes following a review, the pipeline plugin could "flush" the changes through all of the dependent branches, which was incredibly slick.

What I'd like to do is get as close to this workflow with git and github.

Currently I just hold off proposing branches that depend on others until they've landed. I can still branch of the previous branch to keep going, it just means I've got to manually deal with updating the current branch with any changes that happen in the first. This feels clunky though.

So how do you manage these scenarios sanely? Is a 'pre-requisite branch' feature something that is missing from github?

Show Comments