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 learn to update from a remote.

Fetching

Let's find out how the repository evolved, from your coworker perspective. Go into the theirs repository:

cd ../theirs
jj
@  s    (empty)
◆  u    main
│
~

Only main is visible. Makes sense, your coworker hasn't yet declared any intention to work on foo and bar, so those remote branches are hidden:

$ jj bookmark list -a
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)

Declare that you want to track them:

jj bookmark track "*" --remote=origin
@  sz   (empty)
│ ○  st   foo
├─╯
│ ○  o    bar
├─╯
◆  u    main
│
~

There they are, as expected.
Notice that your coworker doesn't see your Change k yet:

○  k    foo Hello, world

This is consistent with Git: a local and a remote repository align only during fetch and push operations. This means that:

foo@origin: stnkrwop 00687915 (no description set)

shall be interpreted as the last known position of the remote Bookmark foo on origin.

Fetching From a Remote

I imagine you know what happens if you run a fetch:

jj git fetch
@  sz   (empty)
│ ○  k    foo Hello, world
│ ○  st
├─╯
│ ○  o    bar
├─╯
◆  u    main
│
~

There's k! Notice how foo (and consequently foo@git) aligned with the new position of foo@origin:

$ jj bookmark list foo
foo: ksvskswq 938fe989 Hello, world
  @git: ksvskswq 938fe989 Hello, world
  @origin: ksvskswq 938fe989 Hello, world

In essence:

jj git fetch [--remote=origin]

tells Jujutsu:

  • To retrieve every Change from the origin remote and integrate it into the local repository.
  • If possible, to update the position of every remote Bookmark.
  • If possible, to align each local Bookmark to the remote Bookmark it's tracking.

Why did I say "If possible"? Because things don't always go this smoothly. Indeed: enough with the happy paths! Time to shake things up a little.
In the next page you'll try to sort out a situation where you and your fictional coworker have updated the same remote Bookmark in 2 irreconcilable ways.