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

Reset your progress

To reset your progress to the start of this chapter, run the following command:

curl https://s2p2.github.io/jj-for-everyone/reset.sh | bash -s merge
cd ~/jj-tutorial/repo

To combine changes from multiple commits, create a merge commit. A merge commit has two or more parent commits.

The command jj commit actually does two things at once:

  • Adds a description to the commit you just finished.
  • Starts a new commit on top of it.

Unfortunately it can't create merge commits.

jj new is used for merges because it can specify multiple parents.

Create a merge commit from main@origin and the previous commit (@-):

jj new main@origin @-

The jj log graph now shows a new commit with two parents:

@    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 project description to readme
~

Confirm that the new commit contains the combined changes:

cat README.md
cat hello.py

If changes overlap, Jujutsu creates a conflict that you must resolve manually. This is a topic for a later chapter.

Finally, add a description to the merge commit, update the main bookmark, and push:

jj commit -m "Merge code and documentation for hello-world"
jj bookmark move main --to @-
jj git push

By default, jj log now hides this merge history. To view all commits, use jj log --revisions 'all()' or jj log -r 'all()'.