Is there a Graphite-y way to restack onto a commit...
# how-do-i
b
Is there a Graphite-y way to restack onto a commit from main, but not the latest? I'm landing commit 1 with a codemod script, and commit 2 with the output of that script. It'll conflict with everybody's branches... to resolve it, I want them to restack onto commit 1, run the codemod script and
gt modify
those changes in, and then they can restack onto main. Any ideas how to best do this?
j
we don't have a great way to do this unfortunately. I suppose my suggestion would be to distribute the script separately
b
follow up q in case you have ideas -- is there a way to run the codemod on all commits in a branch, since otherwise rebasing will cause conflicts all the way up
(of course, if everyone did
gt modify
, there would only be one commit per branch 😬 )
Oooh, one idea for the original question: Maybe I could have them
gt sync
, which wouldn't rebase cause of conflicts, then they could cherry-pick the commit from
main
onto their own branch, then they could run it...
j
if folks dont mind `gt squash`ing just this once...
cherry pick sounds like a good idea, if they have branches stacked on top they'll need to restack them put makes sense to me
and then rebasing the branch on main later should drop the cherry picked commit
b
ah nice, okay that sounds like a plan
is there an equivalent command for non-graphite users to
gt squash
? I guess that's just smooshing all the commits beyond main together, since non-gt users won't be stacking in that way...
j
git reset --soft <firstcommitinbranch> && git commit --amend
the first command points the branch at its first commit and stages all the changes of the later commits
b
amazing, thank you!