1

If I create a Pull Request from a branch

git checkout -b branch-for-first-PR
# edits and commits
git push origin branch-for-first-PR

do some work in it, and then want to experiment with building on that while the first PR is getting reviewed I might do

git checkout branch-for-first-PR
git checkout -b branch-for-second-PR
# edits and commits
git push origin branch-for-second-PR

The problem that I'm having is that the diffs for the second PR show all the changes in the first which is confusing for reviewers.

Is there a structured way to indicate to code review tools (I'm just using Github at this point) that one patch depends on another patch under review? Ideally something like Google's internal DIFFBASE= that gives the reviewer the option of ignoring hunks that are unchanged from the first PR.

2
  • Git doesn’t do pull requests. That’s software on top of Git. So an answer would be 100% dependent on the software in use.
    – Daniel B
    Commented Sep 22, 2021 at 16:11
  • @DanielB I'm aware of that. I'm wondering if, for Github as mentioned, there is one, or if there's some convention that multiple CI systems respect. Commented Sep 22, 2021 at 19:08

1 Answer 1

1

I would think that as long as the first branch is not yet merged to e.g. master then your second PR will show all changes from the first as well.

If branch-for-first-PR is merged then your second PR will show only the changes done there.

branch1 --------------------------------
            |
            --- branch 2 ---
                           |
                           --- branch 3

Diff between branch 1 and branch 3 will also show changes done in branch2, but if:

branch1 --------------------------------------
            |              | Merge to branch 1
            --- branch 2 ---
                           |
                           --- branch 3 --- 

If Branch 2 is merged into branch1 at the start of branch 3 then :

Diff between branch1 and branch 3 will only show branch3 changes

2
  • If main hasn't been merged into the second since the first was merged into main then why wouldn't the second PR show the changes from the first? Commented Feb 25, 2022 at 0:44
  • Added some more info to my post above to illustrate.
    – Linuxdevel
    Commented Feb 28, 2022 at 14:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .