> So now we get to the issue: git would want us to rebase every one of these branches individually.
> [..]
> We only get one branch. So what we'd have to do is go back and fix up every single branch here, including our merge.
Not really, sounds close to git's --rebase-merges (formerly --preserve-merges):
git rebase --onto main@origin main 79d7cf16869f0f293b18ff4fa339d2d053b537c0 --rebase-merges
I'm guessing putting "--update-refs" on top of it would give you exactly what you want. I also have a version without it though.
Re:JJ Cheat Sheet
by steveklabnik on Thursday February 13, 2025 @01:48PM
(#43039655)
Ah nice, thank you!
Just to be clear, `jj` stores all of its stuff in a real git repo. I know you probably meant "using git instead of jj" but I wanted to point that out because it means that you can just go look at what it does. I will say that sometimes that can be confusing, and I'd be very careful running git commands that modify history inside that directory.
So for example, here's a simple mega merge:
the first commit after the root is bookmarked as `main`, our three changes are on top of it, with a mega merge.I've used a colocated repo, so the `.git` dir is at the top level, so we can just run `git log`:
So this is the initial state.Let's say that we pull down our remote, and main has changed, as you've said. There is a new commit on top of it.
We can simulate this in jj. (q is valid because we have so few changes there's no others that start with q yet)
here's our log in `jj`: and in `git`: So now we get to the issue: git would want us to rebase every one of these branches individually. When we rebase A (19d713aab65d0e572994634b2487ce7637d6752a) on top of main@origin (c8318f5fd641a9b271b67e90e7ca1c465b1a92da), well: (don't do this in a real repo, since this is an example I'm okay with trashing things, I even made a copy of the repo before doing this) We only get one branch. So what we'd have to do is go back and fix up every single branch here, including our merge. And so yeah, you can do it, but it's a giant pain in the butt. And for the children, you really need --onto, so you'd end up doing something like for every branch. HOWEVER, git has introduced --update-refs, which can automate this. But it's from 2022, and my Ubuntu is a bit old, and so I cannot actually try it out.That allll being said, I also don't know how well --update-refs does with the mega merge commit itself.
> this seems like a lot of boilerplate to always recreate my megamerge setup so I think I'm missing something
I mean, the entire thesis here is that stuff is easier in jj than it is in git: it doesn't mean you're missing something it means that git can be a bit clunky sometimes.