Intermezzo: A Taste Of a Fanciful Workflow
Indulge me in a little digression.
Why create a commit in the middle of a branch? How frequent can this use case possibly be?
I’m glad you asked! It’s the basis of powerful workflows you might eventually love. We explore this in Dispatching Edits from Megamerges. Here’s a preview.
Say you have 3 local branches:
@ u **feat-3**
○ tn
○ y
│
│ ○ n **feat-2**
│ ○ k
├─╯
│ ○ m **feat-1**
│ ○ l
│ ○ p
├─╯
~
CI/CD will eventually merge them, but why wait? You can merge locally
, and get rid of the merge with jj abandon in a breeze. Without
further ado:
@ kx
○ x Megamerge
├─┬─╮
│ │ ○ u **feat-3**
│ │ ○ tn
│ │ ○ y
│ ○ │ m **feat-1**
│ ○ │ l
│ ○ │ p
│ ├─╯
○ │ n **feat-2**
○ │ kt
├─╯
~
You might wonder: how did I create merge commit
xwithout ajj mergecommand?
Believe it or not, you already have the ingredients to figure it out. Think about it. The answer is coming up in two pages.
Now, say you need to develop feat-2. Why not work directly from the
megamerge, ensuring feat-2 integrates smoothly with the other 2
branches immediately?
Do your work in kx. When finished, add a new empty Change on top of feat-2:
@ kx
○ x Megamerge
├─┬─╮
│ │ ○ u **feat-3**
│ │ ○ tn
│ │ ○ y
│ ○ │ m **feat-1**
│ ○ │ l
│ ○ │ p
│ ├─╯
○ │ s <--- new Change
○ │ n **feat-2**
○ │ kt
├─╯
~
Then, you send your work from kz back to the empty commit s using
jj squash -t s (you’ll learn how to dispatch edits soon).
Sounds insane? It is! I was also shocked the first time. It didn’t take long before it felt more useful than weird. It’s now one of my daily drivers. You might find it convenient too.
Let’s continue; you’re close to mastering the basics.