Skip to main content

Jujutsu Version Control: Using Github

·3 mins

When working with version control you usually have your project in a remote repository using a service like GitHub, GitLab, or Bitbucket. This article shows how to put your Jujutsu repo on GitHub and push changes to GitHub. Most of the material in this article also applies to services like GitLab and Bitbucket.

Create a GitHub Repository #

If you have not created a repository for your project on GitHub, you must do so. Sign into GitHub and create a new repo.

Putting Your Jujutsu Repository on GitHub #

You must perform the following steps to put your Jujutsu repository on GitHub:

  1. Add a remote branch for the GitHub repo.
  2. Set a bookmark for the Jujutsu repo.
  3. Push the Jujutsu repo’s changes to GitHub.

Add a Remote Branch #

Run the jj git remote add command to add a remote branch. Supply the name of the remote branch and the URL of the GitHub repo.

jj git remote add origin https://github.com/GitHubAccount/RepoName.git

Replace GitHubAccount with your GitHub username. Replace RepoName with the name of your GitHub repo.

Set a Bookmark for the Jujutsu repo #

To put your Jujutsu repo on GitHub, you must create a bookmark and point it to a change in your repo. A Jujutsu bookmark is similar to a git branch. Run the jj bookmark set command to set a bookmark. Supply the name you want for the bookmark, add the --allow-backwards and -r options, and supply a change ID.

In most cases you should point the bookmark to the most recent change you made. Run the jj status command to check if the working copy is empty. The following output indicates an empty working copy:

The working copy has no changes.
Working copy  (@) : tuovlrqq bca1068a (empty) (no description set)
Parent commit (@-): mqyvuonk e42670a9 Add section on creating a GitHub repo.

If the working copy is not empty, point the bookmark to the working copy by passing @ as the change ID. If the working copy is empty, point the bookmark to the working copy’s parent commit by passing @- as the change ID.

The following command sets a trunk bookmark for an empty working copy:

jj bookmark set trunk --allow-backwards -r @-

After setting the bookmark the first time, you can omit the --allow-backwards option when setting that bookmark in the future.

jj bookmark set trunk -r @-

Push Changes to GitHub #

Run the jj git push command to push the changes from your Jujutsu repo to GitHub. Supply the --allow-new and -b options along with the name of the bookmark. The --allow-new option allows creating new bookmarks, which you need to do the first time you push.

jj git push --allow-new -b trunk

If you don’t supply the -b argument, Jujutsu issues a warning about the working copy commit becoming immutable.

After pushing a bookmark the first time, you can run the jj git push command without any options.

jj git push

Unfortunately you have to set the bookmark every time you push. If you run the jj git push command to push to the trunk bookmark without resetting the bookmark, Jujutsu tells you the bookmark matches and there are no changes to push.