How do I add a branch in the middle of a stack? I ...
# how-do-i
p
How do I add a branch in the middle of a stack? I thought I created one, but it somehow got lost.
Copy code
* a4d4eca8 - (HEAD -> paul/09-20-Add-Account.account_settings) Add Account.account_settings (78 seconds ago)<Paul Sadauskas>
* 5ad00077 - Added AccountSettings (78 seconds ago)<Paul Sadauskas>
* 4e3d3937 - (paul/09-20-Removed-redundancies-from-PlaceholderTheme) Removed redundancies from PlaceholderTheme (55 minutes ago)<Paul Sadauskas>
* 5a4b8bb2 - (paul09-20-Remove-underscores-from-theme-strings) Remove underscores from theme strings (58 minutes ago)<Paul Sadauskas>
I'd like one for that
5ad00077
in middle there. I tried
gt split --by-commit
, but I get "ERROR: This command cannot be run with uncommitted changes.", which I'm hoping to avoid cleaning all that up at this point.
v
If it's complaining about uncommited changes, how about just stashing those, then doing the action and then unstashing?
p
Different error: "ERROR: Cannot perform this operation on untracked branch paul/09-20-Add-Account.account_settings. You can track it by specifying its parent with gt track." That's the branch that got lost.
v
I guess that means you are on your local version of your "lost branch". So which state is the correct one? The one you have checked out currently, or the 5ad00077?
p
Yeah, I figured it out. I checked out the missing branch, then did a reset --hard to point it at the new rebased sha.
👌 1
Should I not be doing a fixup commit targeting a commit in the middle of the stack, then? Looks like the preferred way is to checkout the middle branch, and then amend? https://graphite.dev/docs/update-mid-stack-branches#amend-commits
v
I guess it is a bad idea to do a fixup commit for a not-checked out branch mid-stack, yeah
p
Oh, I don't even
git commit --amend
, I have to use
gt modify
instead. This is gonna take some breaking of habits, I think 😄
v
You probably can
gt co
the branch in question, then do fixup commits and then use
gt m --interactive-rebase
or directly use
gt m
if the commit to fixup is the latest
l
How do I add a branch in the middle of a stack?
Have you tried?
gt branch create --insert
s
I also wanted to insert a branch between 2 other branches in the stack. This is actually done with
gt create --insert
Works like a charm ;)