Why does `gh stack rebase --upstack` include the current branch?
Say I have the following stack
main <- branch1 <- branch2 <- branch3
I'm on branch1, and just addressed some reviewer feedback by adding a few extra commits. Now I need to do the following:
- rebase
branch2onbranch1 - rebase
branch3onbranch2
I do not want to rebase branch1 on main right now.
My instinct is to call gh stack rebase --upstack while on branch1, where I just addressed the feedback and added commits. I was expecting that to do what I outlined above and not change branch1 in any way.
Surprisingly (to me), it did this:
- rebase
branch1onmain - rebase
branch2onbranch1 - rebase
branch3onbranch2
Can I ask about why --upstack includes a rebase of the current branch on the branch under it? That actually feels a bit "down stack"-ish to me.
It feels like this exact workflow is going to be pretty common for me, and the current workaround is for me to gh stack switch up to branch2 and then run gh rebase --upstack, but that feels pretty unnatural to me!
One way I think about it is that gh stack rebase does all of this:
- rebase `branch1` on `main`
- rebase `branch2` on `branch1`
- rebase `branch3` on `branch2`
The union of gh stack rebase --downstack and gh stack rebase --upstack should be gh stack rebase, so you can divide the work like this if you are on branch1 right now:
gh stack rebase --downstack gets:
- rebase `branch1` on `main`
gh stack rebase --upstack
- rebase `branch2` on `branch1`
- rebase `branch3` on `branch2`
that has a nice symmetry to me, and matches my intuition (and more importantly, my workflow) a bit more
FYI I read https://github.github.com/gh-stack/ in detail, got very excited about it because it matches my workflow (see the "stack" of 7 PRs here https://github.com/posit-dev/ark/pull/1298 through https://github.com/posit-dev/ark/pull/1305), and have asked to be in the private beta, but am not in it yet.
But I discovered that the CLI tool still basically works as is, even without the GitHub side UI being turned on, so I've been using gh stack anyways 😬. But if you have any sway over who gets in the beta, I'd be happy to continue to give feedback!