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

Goal

You create 2 repository with a shared remote, and you will learn to control remote branches.

Tracked and Tracking Bookmarks

A local Bookmark can be bound to a Bookmark on a remote repository. One will follow the other.
The two Bookmarks will have these roles:

BookmarkRoleMeaning
LocalTrackingMonitors the position of a remote Bookmark and tries to stay aligned with its position, following a git fetch
RemoteTrackedTries to align with the position of a local Bookmark during a git push.

With the next commands we'll create 3 repositories on the local filesystem:

RepositoryDescription
project-remoteA bare repository to use as a remote.
oursA clone of project-remote. It will be your working repository.
theirsA second clone of project-remote. It will be the working repository of a hypothetical coworker of yours.

It's an extraordinarily simple repository: only 3 commits. Yet, plenty to chew on anyway to learn a lot. Let's begin:

git clone ssh://git@codeberg.org/arialdo/jj-remote.git project-remote --bare
jj  git clone project-remote ours
jj  git clone project-remote theirs
cd ours

Displaying Remote Bookmarks

Both Git and Jujutsu show only the main branch.

$ git log --oneline --graph
* 7dac65a (HEAD, origin/main, main)

$ jj l
@  p    (empty)
◆  u    main
│
~

and both reveal the existence of the remote branches if asked to:

$ git branch -a
* (no branch)
  main
  remotes/origin/bar
  remotes/origin/foo
  remotes/origin/main

$ jj bookmark list --all-remotes
bar@origin: ossuomlo fa22ec04 (no description set)
foo@origin: stnkrwop 00687915 (no description set)
main: urvnvxtx 7dac65ac (no description set)
  @git: urvnvxtx 7dac65ac (no description set)
  @origin: urvnvxtx 7dac65ac (no description set)

Learn to read the jj bookmark list output. It tells you:

  • bar exists only on origin.
  • foo also exists only on origin.
  • main exists as a local Bookmark.
    • As a branch on git.
    • And as a Remote Bookmark on origin.

The indentation under main helps visualizing that it is tracking 2 remote Bookmarks: the one on git and the one on origin. These 3 bookmarks will do their best to stay aligned with each other. In fact, right now all 3 point to the same commit 7dac65ac.