Skip to content

Editing history

In jj, rewriting history is everyday work, not a risky escape hatch. When you change a commit, Wyrm rebases everything on top of it for you. Every edit below is one operation, so undo takes it back.

By default jj treats your trunk (such as main@origin) and tags as immutable and refuses to rewrite them. The 🛡 toggle overrides that when you really mean it.

Most commands live in the right-click menu of a commit in the log, under Commit operations. The less common ones are under More.

Select the commit and choose Split…. In Split commit, tick the files that should go into the first commit, or open a file’s hunks and pick single hunks. Click Split. The rest stays in a second commit on top.

You can also split straight from the diff: each hunk header has a Split button.

  • Squash to parent (S): fold the selected commit into its parent.
  • Squash into another commit: select the commit, then right-click the commit you want to fold it into and choose Squash … into ….
  • Several commits at once: select a run of neighbouring commits and choose Squash N commits together.
  • Squash with options… (under More) can keep the emptied commit, or keep only the parent’s description.

Fixed a few things in your working copy that belong in older commits? Select @ and choose Absorb into ancestors (A). jj moves each changed line into the commit that last touched it, and leaves anything it can’t place in @.

In the diff of any commit, each hunk header has four buttons:

  • Squash ↑: move the hunk into the parent commit.
  • Move…: move it into any other commit.
  • Split: split it out into a commit of its own.
  • Discard: drop it from this commit, so the file goes back to the parent’s version there.

To act on several hunks, tick them (Space ticks a hunk); ⇧-click picks single lines. The bar above the diff shows how many hunks and lines are selected. With a selection, ⇧S squashes it and ⌫ discards it. Discarding asks first. Binary, renamed or conflicted files only offer whole-file actions.

Right-clicking a hunk offers the same moves: Squash hunk to parent, Discard hunk changes, Move hunk to….

In the revision pane, select one or more files and use Squash into parent, Move to… or Restore files. Move to… opens Move changes to…: enter the Destination revision (a bookmark, a change ID or a revset) and click Move.

You can also drag a file or a hunk onto a commit in the log and choose Squash here.

Right-click a file in a commit’s changes:

  • Edit in this revision… opens the file as it is in that commit. Save with ⌘S: Wyrm rewrites that commit and rebases its descendants onto it.
  • Delete from this revision… removes the file from that commit only; later commits are rebased.

The files panel has the same two actions.

  • Reorder (R, with two or more commits selected): drag them into the order you want and click Apply Reorder.
  • Drag and drop: drag a commit onto another to Rebase here, onto the line between two commits to Insert here, or onto a merge to add it as a parent.
  • Rebase onto another commit: select the commit, right-click the destination and choose Rebase … onto ….
  • Restore from parent, Duplicate, Backout (revert) and Abandon… are in the same right-click menu. More adds Change parents…, Simplify parents, Restore from… and the other variants.

If a rewrite creates a conflict, jj records it in the commit instead of stopping you. See Resolving conflicts.