How do I split one PR in a stack into multiple? Fo...
# how-do-i
d
How do I split one PR in a stack into multiple? For example right now I have branch A which is the parent of branch C. I want to insert branch B in between the two and split up the changes currently contained in branch A. I inserted the branch with
gt branch create --insert b
, and now I have the stack A->B->C. However, if I start removing some changes from branch A, they'll also get removed from branch B due to graphite rebasing. I want to keep those changes in branch B in order to split up the PR.
✅ 1
b
have you tried
gt branch split
to split the changes in branch A? https://graphite.dev/docs/squashing-folding-and-splitting
d
ah, I didn't know about this command. I think that hunk mode will more or less do what I want.
although it would probably be easier to incrementally make changes than need to figure out which code I want to split and which I don't all at once
a
I do this pretty often, and my workflow is: 1. Make a large branch with all my changes in a single commit 2. Use
git reset HEAD~
3. Create as many commits as I want there to be branches at the end 4.
gt branch split
using commit
d
Yeah that makes sense. I can't split by commit though. I inherited this stack from someone else and I'm trying to split it up more. The commits in this branch wouldn't split how I want to. I want to split by code functionality. I'm not entirely sure which code is doing what yet so being able to incrementally make changes to which code is in what branch is ideal
hmmm idt hunk is going to work actually. It's too confusing to try and split all from within the cli editor for the number of changes I'm working with. It'll be much easier to just make two completely new branches
ideally what I would like to do is insert branch b, then in branch a checkout main for certain files where I know I want the entire thing to be in the new branch b. Other cases maybe make some custom changes or only get rid of part of the changes in the file. Then I would want to be able to commit to branch A with some sort of flag that won't automatically rebase those changes into branch B? I imagine there is a way that I could essentially say "hey, I want to keep these changes in the child branch" and then if I made any custom changes to branch A resolve them as rebase conflicts.
this would make it easier to get split up a couple of files at a time, do some testing, then move onto another batch
rather than trying to look at every single part of the diff in a PR that spans several files and several hundreds of lines of code all at once when splitting