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

Adding more bookmarks

Let's switch back to Alice:

cd ~/jj-tutorial

She heard rumors that next week's assignment is going to be about writing loops in Python. In an attempt to stay ahead of the game, she extends the hello-world program with iteration:

echo "
for (i = 0; i < 10; i = i + 1):
    print('Hello, world!')" >> hello.py

Unfortunately, she seems to have made a mistake. Running python hello.py prints an error:

  File "/home/remo/jj-tutorial/hello.py", line 3
    for (i = 0; i < 10; i = i + 1):
         ^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

Alice doesn't have time to figure out the problem. She decides it's best to wait for the teacher to explain how to do it correctly in next week's lecture. She doesn't just want to throw her changes away though, she wants to keep the experiment around so she can compare it to the correct version later. As usual, she describes her changes and makes a new commit before pushing:

jj describe -m "WIP add for loop (need to fix syntax)"
jj new

Pushing work-in-progress (WIP) changes like this directly to the main bookmark would be a bad idea. Imagine if Bob later created a submission tarball and it accidentally included Alice's incomplete, incorrect code! That would be no good. To avoid that, Alice decides to push her commit to a new bookmark.

What should be the name of that bookmark? Having a main bookmark is a strong convention, but for additional ones, anything goes. A simple approach is to just use a super short description of your changes, like add-for-loop. Some people like to prefix their bookmark names with their own name or username, allowing everyone to easily identify who's working on what: alice/add-for-loop. Still others include a ticket number from the bug-tracker software in the bookmark name. These are all fine options, but sometimes you just don't care. Jujutsu has a handy way to push changes by generating a generic bookmark name for you:

jj git push --change @-
@  qrtwnykn alice@local 2025-07-25 20:37:05 c2f4e43e(empty) (no description set)rvpkroku alice@local 2025-07-25 20:37:05 push-rvpkrokuqrxt git_head() b9d02faf
│  WIP add for loop (need to fix syntax)
  stlxrmun alice@local 2025-07-25 20:37:05 main 530ad636(empty) Combine code and documentation for hello-world
~

The name of the generated bookmark is push-, followed by a prefix of the change ID. It's not very informative, but that's kind of the point. The content of the commit is what's important, the bookmark is only needed to send it to the remote.

Note that the --change flag can be abbreviated as -c. You might be noticing a pattern here, many commonly-used flags have these short versions. You can explore the available flags of any Jujutsu command by calling it with the --help flag, e.g. jj git push --help.

Alice's experiment with Python loops is now safely stored on the remote with a bookmark, but it doesn't interfere with unrelated work progressing on the main branch. Great!