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

Sending commits to a remote

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 remote
cd ~/jj-tutorial/repo

Your commits are stored locally, which means they are not backed up. To back up your work and collaborate with others, you can send your commits to a remote.

While services like GitHub are common, this tutorial uses a simple local directory as a remote for learning purposes. This method is not suitable for real-world backups or collaboration but is perfect for understanding the mechanics.

Initialize the Remote

First, create a "bare" Git repository to serve as the remote. A bare repository contains only version history, with no working copy of the files.

git init --bare -b main ~/jj-tutorial/remote

The difference between remote (bare) and regular repositories

A regular Jujutsu repository has two parts: (1) the internal database (.git and .jj directories) and (2) the working copy of your files that you can edit.

A "bare" repository is a Git repository without a working copy. Since we only use the remote for sending and receiving commits, a working copy isn't needed. The -b main flag sets the default branch name to "main".

Connect to the Remote

Next, connect your local repository to the remote. By convention, the primary remote is named origin.

jj git remote add origin ~/jj-tutorial/remote

For a service like GitHub, you would use a URL instead of a local path. Verify the remote was added:

jj git remote list

Add a Bookmark

To push a commit, you must first attach a bookmark to it. Bookmarks are named labels that mark important commits to be kept on the remote.

Let's create a bookmark called main, a common convention for the project's primary state, and point it to your commit.

jj bookmark create main --revision mkmqlnox # <- substitute your change ID here

The command jj bookmark create expects a name (main) and a commit to which the bookmark should point. We identify the commit by its change ID (--revision mkmqlnox). The flag --revision can also be abbreviated as -r. Let's check the result with jj log:

@  pwpuwyto alice@local 2025-07-22 20:22:36 35de496a
│  (empty) (no description set)
○  mkmqlnox alice@local 2025-07-22 20:20:34 main git_head() 5b79353a
│  Add readme with project title
◆  zzzzzzzz root() 00000000

The output shows the main bookmark pointing to your commit.

Track a bookmark

We are now learning about bookmarks because we want to send commits to a remote. However, bookmarks can also be used for local-only purposes. You may not want to send all of your bookmarks to a remote.

Jujutsu identifies bookmarks which are supposed to be sent to a remote with a "tracking" state. In order to send the main bookmark to our remote, we need to "track it" first:

jj bookmark track main@origin

The @origin part means that main should be sent to the remote called origin.

Push the bookmark

Now that we're connected and have a tracked bookmark, let's finally send our commit to the remote. The technical term for sending commits is "pushing" them.

jj git push --bookmark main