LinuxCommandLibrary

jj-duplicate

Duplicate an existing commit

TLDR

Duplicate the current revision onto its existing parent

$ jj duplicate
copy

Duplicate a specific revision onto its existing parent
$ jj duplicate [revset]
copy

Duplicate a revision onto a different parent
$ jj duplicate --destination [dest_revset] [revset]
copy

Duplicate a revision and insert it **after** other revision(s)
$ jj duplicate --insert-after [after_revset] [revset]
copy

Duplicate a revision and insert it **before** other revision(s)
$ jj duplicate --insert-before [before_revset] [revset]
copy

Duplicate onto multiple parents (creates a merge commit)
$ jj duplicate --destination [destination1] --destination [destination2] [revset]
copy

Duplicate multiple revisions
$ jj duplicate [revset1 revset2 ...]
copy

SYNOPSIS

jj duplicate [-r REVISION] [--dest DEST] [--insert-above REVISION] [--insert-before REVISION]

PARAMETERS

-r, --revision <REVISION>
    Revision(s) to duplicate (default: @, the working copy)

--dest <DESTINATION>
    Explicit destination commit for the duplicate

--insert-above <REVISION>
    Insert duplicate above the given revision

--insert-before <REVISION>
    Insert duplicate before the given revision

DESCRIPTION

The jj duplicate command in Jujutsu (jj), a Git-compatible version control system, creates a duplicate of the specified revision(s), typically the working copy by default. This is useful for branching or starting parallel work without altering the original changes.

It duplicates the commits from the given revision to a new destination, preserving history while allowing independent development. The duplicate appears as an unpushed, editable commit in the working-copy-like state, enabling immediate modifications.

Common use cases include duplicating the working copy for experimentation (jj duplicate) or duplicating a specific commit (jj duplicate main). Options allow precise control over the destination and insertion point, making it a lightweight alternative to traditional branching in Git.

Unlike Git's branch, which only creates a pointer, jj duplicate materializes a new commit copy, aligning with Jujutsu's git-like but operation-focused model for easier conflict resolution and history rewriting.

CAVEATS

Requires a Jujutsu repository; duplicates are editable but may need jj rebase or jj squash for integration. Not suitable for duplicating across divergent histories without manual resolution.

EXAMPLES

jj duplicate
jj duplicate -r main
jj duplicate --dest new-branch main

HISTORY

Introduced in Jujutsu v0.1.0 (2022) by Martin von Zweigbergk as part of core workflow tools. Evolved in v0.18+ with improved multi-revision support and insertion options for better usability over Git's model.

SEE ALSO

Consult jj duplicate --help or jj help revision for full details.

SEE ALSO

jj(1), jj new(1), git branch(1), git checkout(1)

Copied to clipboard