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

Rebasing a Branch

Goal

In which you rebase a branch, then you rebase it back to where it was.

If you run jj undo from the previous page, your history tree should be:

  ○  zx       Click alternates Xs and Os main        <--- this branch
  ○  v        Click sets an X
  ○  s        Square has state
  │ ○  o        Play instructions
  │ ○  kx       Play manual
  ├─╯
  ○  n        Square is interactive
  ○  ru       Board() invokes Square()
  ~

How would you rebase the branch from s to zx on top of o?

Solution

The solution is almost the literal translation of the request:

$ jj rebase -r "s::zx" -o o

You should get to:


  ○  zx       Click alternates Xs and Os main
  ○  v        Click sets an X
  ○  s        Square has state
  ○  o        Play instructions
  ○  kx       Play manual
  ○  n        Square is interactive
  ○  ru       Board() invokes Square()
  ~

How would you undo that, using rebase and not undo?

Solution

The original base of s::zx was n, so the move is:

$ jj rebase -r "s::zx" -o n

○  zx       Click alternates Xs and Os main
○  v        Click sets an X
○  s        Square has state
│ ○  o        Play instructions
│ ○  kx       Play manual
├─╯
○  n        Square is interactive
○  ru       Board() invokes Square()
~

Give yourself a pat on the back if you got it right.