Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
github code review workflow for branches
Thought I would document something that helps speed up github code review process for people who have lots of PR's in flight that build
on top of each other
My normal workflow involves
1. Branch off of master for PR1 on branch branch_pr1
2. Submit a PR from branch_pr1 (head of this branch is sha_pr1_old)
3. Wait for code review comments ##
4. Continue development for PR2 on branch_pr2 which is off of branch_pr2 (you have branched off at sha_pr1_old)
5. Submit a PR from branch_pr2
6. When you get code review feedback for branch_pr1, incorporate it and squash them back on branch_pr1 (to keep a clean history on github)
Now you need to rebase branch_pr2 to pull in these changes
Often you end up with a 3 way merge conflicts; even though pr2 was really self contained.
The easiest way to fold the changes from PR1 onto PR2 is
git rebase --onto parent_branch <branch~n|sha> branch
where branch~n is the commit where you originally branched from PR1 (before PR1 accomodated the changes)
e.g
git rebase --onto branch_pr1 branch_pr2~1 branch_pr2 (if you only had one new commit in branch_pr2)
OR
git rebase --onto branch_pr1 sha_pr1_old branch_pr2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment