LinuxCommandLibrary

jj-split

Split a commit into multiple new commits

TLDR

Split the given revision into two interactively, putting the second revision on top of it

$ jj split [[-r|--revision]] [revision]
copy

Split out matching files from the given revision
$ jj split [[-r|--revision]] [revision] [fileset]
copy

Split the given revision, putting the second revision on top of given destination(s)
$ jj split [[-r|--revision]] [revision] [[-d|--destination]] [revset]
copy

Split the given revision, putting the second revision before and/or after other revision(s)
$ jj split [[-r|--revision]] [revision] [[-B|--insert-before]] [revset] [[-A|--insert-after]] [revset]
copy

Split the given revision into two parallel revisions
$ jj split [[-r|--revision]] [revision] [[-p|--parallel]]
copy

SYNOPSIS

jj split [OPTIONS] [REVISION] [-- PATHS…]

PARAMETERS

-r, --revision <REVISION>
    Revision(s) to split (defaults to working-copy commit "@")

-m, --message <MESSAGE>
    Set commit message(s) for the new revision(s)

--insert-before <REVISION>
    Insert new revision(s) before the given revision

--no-interactive
    Disable interactive hunk selection; split evenly or by paths

-i, --interactive
    Enable interactive mode (default)

--no-edit
    Don't open editor for message

--git
    Make new commits Git-compatible

DESCRIPTION

The jj split command, part of the Jujutsu (jj) version control system, allows users to divide a single commit (revision) into two or more separate commits. It operates interactively by default, prompting the user to select which changes (hunks) to retain in the first new revision, with the remaining changes moved to subsequent revisions.

This is particularly useful for refactoring large commits into smaller, more focused ones, improving commit history granularity without losing work. For example, splitting a commit that mixes unrelated bug fixes and features.

jj split targets the working-copy commit by default but can specify any revision with -r. It preserves the original commit message unless overridden, and the new commits are inserted in place of the original. Non-interactive mode is available via --no-interactive for scripting.

Unlike Git's interactive rebase, jj split leverages jj's change-based model for safer, concurrent-friendly operations.

CAVEATS

Requires Jujutsu installed; interactive mode needs terminal; splitting large changesets can be time-consuming.
Not reversible without jj undo.

INTERACTIVE WORKFLOW

In interactive mode, use space to select hunks, Enter to confirm, q to quit.

PATH FILTERING

Specify paths after -- to split only matching changes.

HISTORY

Introduced in Jujutsu 0.1.0 (2022) by Martin von Zweigbergk. Evolved with jj's Git-compatible rewrite history model, focusing on safe concurrent edits. Active development at jujutsu.vcs.

SEE ALSO

jj(1), git-rebase(1), git-commit(1)

Copied to clipboard