Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 x without a jj merge command?
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.