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

Creating a merge commit

I've strung you along for long enough, let's finally create that version with the combined changes.

There are actually two approaches to achieve this, one of them we'll see later. This time, we're going to create a merge commit. As the name implies, a merge commit merges changes from two (or more!) commits.

Until now, we've created new commits with the command jj new and merge commits are no different. We just have to explicitly specific which commits we want to merge as additional arguments. You can check the log and use the change IDs of the commits or simply exploit that (1) main@origin is pointing to Bob's commit and (2) Alice's commit is the working copy's parent, i.e. @-. A working command is therefore:

jj new main@origin @-

Let's view the result with jj log:

@    twywpklt alice@local 2025-07-22 21:26:35 764f3651
├─╮  (empty) (no description set)
│ ○  zzywylnt alice@local 2025-07-22 21:17:31 main?? main@git f8e44920
│ │  Add Python script for greeting the world
quolxwkk bob@local 2025-07-22 21:22:22 main?? main@origin git_head() 8d538390
├─╯  Document hello.py in README.md
  kxqyrwux alice@local 2025-07-22 21:14:46 ffdf52d0
│  Add projcet description to readme
~

Interesting! The resulting merge commit has two parents - precisely the ones we specified. You can confirm that this new commit contains both changes from Alice and Bob:

cat README.md
cat hello.py

Jujutsu tries to be smart about how to combine changes, but not too smart. Combining changes which modify the same part of the project leads to a conflict. Conflicts are not necessarily bad, they are just a signal that you need to combine some changes manually, making sure to preserve the spirit of what each change was trying to achieve individually. How to resolve conflicts is a topic reserved for the next level.

Let's give this merge commit a description and send it to the remote:

jj describe -m "Combine code and documentation for hello-world"
jj new
jj bookmark move main --to @-
jj git push

Phew! That was intense. If you run jj log now, the complicated branching and merging will be hidden by default. Remember that you can reveal it with jj log --revisions 'all()'.