> One thing though is that I don't quite understand how it would work in the context of a real git repo.

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:

jj log
@ oyktpwwq steve@steveklabnik.com 2025-02-12 13:25:41 79d7cf16
├─┬─┬─╮ (empty) (no description set)
│ │ │ ○ qvqxlymp steve@steveklabnik.com 2025-02-12 13:25:34 9403fc75
│ │ ├─╯ (empty) C
│ │ ○ wrqmrkot steve@steveklabnik.com 2025-02-12 13:25:32 2df38e4e
│ ├─╯ (empty) B
│ ○ oluunuku steve@steveklabnik.com 2025-02-12 13:25:29 19d713aa
├─╯ (empty) A
○ vukunsxq steve@steveklabnik.com 2025-02-12 13:25:25 main git_head() d29e7411
│ (empty) (no description set)
◆ zzzzzzzz root() 00000000

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`:

git log --graph --all
*---. commit 79d7cf16869f0f293b18ff4fa339d2d053b537c0 (refs/jj/keep/79d7cf16869f0f293b18ff4fa339d2d053b537c0)
|\ \ \ Merge: d29e741 19d713a 2df38e4 9403fc7
| | | | Author: Steve Klabnik <steve@steveklabnik.com>
| | | | Date: Wed Feb 12 13:25:41 2025 -0600
| | | |
| | | * commit 9403fc75d2ec85491d990c7322b0f5f8f500fa78 (refs/jj/keep/9403fc75d2ec85491d990c7322b0f5f8f500fa78)
| | |/ Author: Steve Klabnik <steve@steveklabnik.com>
| | | Date: Wed Feb 12 13:25:34 2025 -0600
| | |
| | | C
| | |
| | * commit 2df38e4eccbd31ef70a810dd86c637cc2110912c (refs/jj/keep/2df38e4eccbd31ef70a810dd86c637cc2110912c)
| |/ Author: Steve Klabnik <steve@steveklabnik.com>
| | Date: Wed Feb 12 13:25:32 2025 -0600
| |
| | B
| |
| * commit 19d713aab65d0e572994634b2487ce7637d6752a (refs/jj/keep/19d713aab65d0e572994634b2487ce7637d6752a)
|/ Author: Steve Klabnik <steve@steveklabnik.com>
| Date: Wed Feb 12 13:25:29 2025 -0600
|
| A
|
* commit d29e7411f098bba0120cfd5b819b732dabcb6f73 (HEAD, refs/jj/keep/d29e7411f098bba0120cfd5b819b732dabcb6f73)
Author: Steve Klabnik <steve@steveklabnik.com>
Date: Wed Feb 12 13:25:25 2025 -0600

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)

jj new v --no-edit -m "changes from upstream"
Created new commit trzwxsrr c8318f5f (empty) changes from upstream

jj bookmark create -r t main@origin
Created 1 bookmarks pointing to trzwxsrr c8318f5f main@origin | (empty) changes from upstream

here's our log in `jj`:

jj log
@ oyktpwwq steve@steveklabnik.com 2025-02-12 13:25:41 79d7cf16
├─┬─┬─╮ (empty) (no description set)
│ │ │ ○ qvqxlymp steve@steveklabnik.com 2025-02-12 13:25:34 9403fc75
│ │ ├─╯ (empty) C
│ │ ○ wrqmrkot steve@steveklabnik.com 2025-02-12 13:25:32 2df38e4e
│ ├─╯ (empty) B
│ ○ oluunuku steve@steveklabnik.com 2025-02-12 13:25:29 19d713aa
├─╯ (empty) A
│ ○ trzwxsrr steve@steveklabnik.com 2025-02-12 13:27:16 main@origin c8318f5f
├─╯ (empty) changes from upstream
○ vukunsxq steve@steveklabnik.com 2025-02-12 13:25:25 main git_head() d29e7411
│ (empty) (no description set)
◆ zzzzzzzz root() 00000000

and in `git`:

git log --graph --all
* commit c8318f5fd641a9b271b67e90e7ca1c465b1a92da (refs/jj/keep/c8318f5fd641a9b271b67e90e7ca1c465b1a92da, main@origin)
| Author: Steve Klabnik <steve@steveklabnik.com>
| Date: Wed Feb 12 13:27:16 2025 -0600
|
| changes from upstream
|
| *-. commit 79d7cf16869f0f293b18ff4fa339d2d053b537c0 (refs/jj/keep/79d7cf16869f0f293b18ff4fa339d2d053b537c0)
|/|\ \ Merge: d29e741 19d713a 2df38e4 9403fc7
| | | | Author: Steve Klabnik <steve@steveklabnik.com>
| | | | Date: Wed Feb 12 13:25:41 2025 -0600
| | | |
| | | * commit 9403fc75d2ec85491d990c7322b0f5f8f500fa78 (refs/jj/keep/9403fc75d2ec85491d990c7322b0f5f8f500fa78)
| | |/ Author: Steve Klabnik <steve@steveklabnik.com>
| | | Date: Wed Feb 12 13:25:34 2025 -0600
| | |
| | | C
| | |
| | * commit 2df38e4eccbd31ef70a810dd86c637cc2110912c (refs/jj/keep/2df38e4eccbd31ef70a810dd86c637cc2110912c)
| |/ Author: Steve Klabnik <steve@steveklabnik.com>
| | Date: Wed Feb 12 13:25:32 2025 -0600
| |
| | B
| |
| * commit 19d713aab65d0e572994634b2487ce7637d6752a (refs/jj/keep/19d713aab65d0e572994634b2487ce7637d6752a)
|/ Author: Steve Klabnik <steve@steveklabnik.com>
| Date: Wed Feb 12 13:25:29 2025 -0600
|
| A
|
* commit d29e7411f098bba0120cfd5b819b732dabcb6f73 (HEAD, refs/jj/keep/d29e7411f098bba0120cfd5b819b732dabcb6f73, main)
Author: Steve Klabnik <steve@steveklabnik.com>
Date: Wed Feb 12 13:25:25 2025 -0600

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)

git checkout 19d713aab65d0e572994634b2487ce7637d6752a
Previous HEAD position was d29e741
HEAD is now at 19d713a A

git rebase main@origin

git log --all --graph
* commit f397936ac0d4510682e68ab470eb81863a5c2a73 (HEAD)
| Author: Steve Klabnik <steve@steveklabnik.com>
| Date: Wed Feb 12 13:25:29 2025 -0600
|
| A
|
* commit c8318f5fd641a9b271b67e90e7ca1c465b1a92da (refs/jj/keep/c8318f5fd641a9b271b67e90e7ca1c465b1a92da, main@origin)
| Author: Steve Klabnik <steve@steveklabnik.com>
| Date: Wed Feb 12 13:27:16 2025 -0600
|
| changes from upstream
|
| *-. commit 79d7cf16869f0f293b18ff4fa339d2d053b537c0 (refs/jj/keep/79d7cf16869f0f293b18ff4fa339d2d053b537c0)
|/|\ \ Merge: d29e741 19d713a 2df38e4 9403fc7
| | | | Author: Steve Klabnik <steve@steveklabnik.com>
| | | | Date: Wed Feb 12 13:25:41 2025 -0600
| | | |
| | | * commit 9403fc75d2ec85491d990c7322b0f5f8f500fa78 (refs/jj/keep/9403fc75d2ec85491d990c7322b0f5f8f500fa78)
| | |/ Author: Steve Klabnik <steve@steveklabnik.com>
| | | Date: Wed Feb 12 13:25:34 2025 -0600
| | |
| | | C
| | |
| | * commit 2df38e4eccbd31ef70a810dd86c637cc2110912c (refs/jj/keep/2df38e4eccbd31ef70a810dd86c637cc2110912c)
| |/ Author: Steve Klabnik <steve@steveklabnik.com>
| | Date: Wed Feb 12 13:25:32 2025 -0600
| |
| | B
| |
| * commit 19d713aab65d0e572994634b2487ce7637d6752a (refs/jj/keep/19d713aab65d0e572994634b2487ce7637d6752a)
|/ Author: Steve Klabnik <steve@steveklabnik.com>
| Date: Wed Feb 12 13:25:29 2025 -0600
|
| A
|
* commit d29e7411f098bba0120cfd5b819b732dabcb6f73 (refs/jj/keep/d29e7411f098bba0120cfd5b819b732dabcb6f73, main)
Author: Steve Klabnik <steve@steveklabnik.com>
Date: Wed Feb 12 13:25:25 2025 -0600

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

$ git checkout 2df38e4eccbd31ef70a810dd86c637cc2110912c
$ git rebase HEAD --onto f397936ac
$ git checkout 9403fc75d2ec85491d990c7322b0f5f8f500fa78
$ git rebase HEAD --onto <new head of branch the first rebase committed>

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.