So I managed to get myself into a sticky situation with JJ where I had squashed together a whole bunch of crappy commits with the intention of then taking the large one and cutting it apart. So I squashed, rebased, then started cutting it apart... only to realize that I had goofed a bit on my squash and included an experimental change I didn’t want to be part of the original commit.
So now what. I tried a few things that ultimately didn’t work. The most promising felt like, jj backout --at-operation <op before squash>
, but nope. Just made divergent history and produced an empty commit that didn’t have anything interesting in it.
The annoying thing was: because of jj log --at-operation
I could see all the stuff I cared about, I just had no idea how to effectively rebase these commits from the future, onto a past where I hadn’t screwed up.
So ultimately I gave up for now. Here’s what I did:
jj op restore <op before squash>
Reset repo state back to where it was prior to the squashjj squash
but the right commits this timejj log --at-operation <after I done my splits and realized I goofed>
. Here I grabbed the git hashes of the splits I wanted to preserve.git format-patch <splits>
; move them out of the working dir lest they accidentally get snapshottedgit am <split patches>
where they ought to go.
Next step for me is to rebase the squashed commit, which means the splits should disappear out of it, and then we’re back where I wanted to be 40 minutes ago.
Oops. Lesson learned.