LinuxCommandLibrary

jj-squash

Combine changes into single commit

TLDR

Move all changes from current revision to its parent

$ jj squash
copy

Move all changes from given revision to its parent
$ jj squash [[-r|--revision]] [revset]
copy

Move all changes from given revision(s) to given other revision
$ jj squash [[-f|--from]] [revsets] [[-t|--into]] [revset]
copy

Interactively choose which parts to squash
$ jj squash [[-i|--interactive]]
copy

SYNOPSIS

jj squash [-r, --revision <REVISION>]

PARAMETERS

-h, --help
    Print help information

-r, --revision <REVISION>
    Revision to squash working-copy changes into (default: working-copy parent)

DESCRIPTION

In Jujutsu (jj), a Git-compatible version control system, jj squash combines changes from the working copy into its parent commit, creating a cleaner history.

This command is ideal for tidying up local commits before sharing. Unlike Git's manual rebase or amend workflows, jj squash operates automatically and safely, leveraging jj's advanced conflict handling and automatic rebase features. It updates the working copy to match the new squashed commit, preserving uncommitted changes if any remain.

When invoked without options, it targets the working-copy parent. Squashing merges the diff from working copy onto the specified revision, effectively discarding intermediate commits in favor of a single, unified change. This promotes concise histories and simplifies collaboration.

Key benefits include non-destructive operation (jj's DAG allows easy undo via jj undo) and seamless integration with jj's change-based model, where commits represent snapshots and changes track diffs.

CAVEATS

Only squashes working-copy changes; committed changes require jj rebase -d or similar. Ensure no concurrent operations to avoid conflicts.

EXAMPLE

jj squash
Squash into default parent.

jj squash -r abc123
Squash into specific revision.

UNDO

Use jj undo immediately after to revert.

HISTORY

Part of Jujutsu (jj) VCS, developed by Martin von Zweigbergk starting 2022 at Google. Squash introduced early for streamlined workflows, evolving with jj's 0.1+ releases to support Git interop.

SEE ALSO

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

Copied to clipboard