Skip to content

Jujutsu GitHub Guide

This is a guide to common Jujutsu workflows with GitHub. It assumes that you have already installed the GitHub cli (gh) and git and Jujutsu (jj).

Start in the directory where you have the code you want to push to GitHub.

If you haven’t already done so, create the local git repository:

Terminal window
git init .

Create the remote repository:

Terminal window
gh repo create --public --source=. --remote=origin **repo-name**

Create the Jujutsu repository:

Terminal window
jj git init --colocate
echo .jj/ >> .gitignore

If (and only if) you created the Jujutsu repository before setting the remote, you will have to tell Jujutsu about it.

Terminal window
jj git remote add origin git@github:**username**/**repo-name**.git

Now do whatever work you want to prepare for the initial push. You can make as many local commits as you want with this command:

Terminal window
jj ci # edit commit message and create a new changeset

When you are finally ready to share your changes, set the main bookmark (or whatever branch name you consider the main line of development):

Terminal window
jj bookmark set main -r @-

-r @- is a reference to the penultimate changeset—the one you just edited the description for. Finally, you can throw it over the wall:

Terminal window
jj git push --allow-new

Subsequent pushes use the same three commands, but drop --allow-new:

Terminal window
jj ci #edit commit message and create new changeset
jj bookmark set main -r @-
jj git push

Again, you can repeat the first command as many times as you want between pushes. This workflow is appropriate in the initial stages of project when you are making frequent changes directly to the primary development branch.

This is a different can of worms that I have not figured out yet.