LinuxCommandLibrary

jj-diff

Show differences between revisions

TLDR

Show changes of current revision

$ jj diff
copy

Show changes of given revsets (e.g. B::D, A..D, B|C|D, etc.)
$ jj diff [[-r|--revisions]] [revsets]
copy

Show changes from given revision to given revision
$ jj diff [[-f|--from]] [from_revset] [[-t|--to]] [to_revset]
copy

Show diff statistics
$ jj diff --stat
copy

Show a Git-format diff
$ jj diff --git
copy

SYNOPSIS

jj diff [OPTIONS] [] []
jj diff [OPTIONS] --from [--to ]
jj diff [OPTIONS] --tool [...]

PARAMETERS

[] []
    Specifies one or two revisions to compare. If one is given, it compares that revision against its parent. If two are given, it compares the first against the second. Defaults to comparing the working-copy commit against its parent.

--from
    Specifies the 'before' revision for the comparison.

--to
    Specifies the 'after' revision for the comparison.

--tool
    Invokes an external diff tool (e.g., `meld`, `vscode`). Tools must be configured.

--stat
    Shows only a diffstat, summarizing the number of lines added/deleted per file.

--summary
    Shows a concise summary of file changes (added, deleted, modified).

--patch
    Displays the full patch output (this is the default behavior).

--no-patch
    Suppresses the full patch output, often used with `--stat` or `--summary`.

--name-only
    Lists only the names of the files that have changed.

--types
    Shows changes in file types (e.g., regular file to symlink).

--reverse
    Swaps the 'from' and 'to' revisions, effectively showing the diff in reverse.

--conflicts
    Shows only unresolved conflicts in the working copy or specified revision.

--exit-code
    Exits with status 1 if differences are found, 0 otherwise. Useful for scripting.

DESCRIPTION

`jj diff` displays the differences between two revisions, or between a revision and the working copy, within the
Jujutsu (jj) version control system. By default, it shows the changes between the current working-copy commit and its parent, making it ideal for reviewing uncommitted work. This command is a core utility designed to provide a more flexible and user-friendly diff experience compared to traditional VCS tools. It can highlight changes made in a specific commit, show uncommitted changes in the working directory, or compare any two specified revisions. `jj diff` also supports integration with external diff viewers, allowing users to leverage their preferred visual diff tools. It's particularly useful for reviewing your work before committing, understanding the impact of a rebase, or inspecting the history of changes, operating seamlessly with Jujutsu's unique graph-based revision model.

CAVEATS

`jj-diff` operates within the Jujutsu (jj) version control system and requires it to be installed. Its underlying data model differs significantly from Git; for instance, the concept of a 'staging area' (or index) does not exist in `jj`. Consequently, `jj-diff` behaves differently from `git diff`, particularly when dealing with uncommitted changes, as it directly compares the working copy. Users transitioning from Git should be aware of these conceptual differences and Jujutsu's unique revision syntax.

DEFAULT BEHAVIOR

When invoked without any arguments (e.g., `jj diff`), the command defaults to showing the changes between your current working-copy commit and its parent. This is highly useful for quickly reviewing your uncommitted work.

EXTERNAL DIFF TOOL INTEGRATION

`jj diff` can be configured to open differences in a variety of external diff tools like `meld`, `vscode`, `kdiff3`, etc. This is managed via the `jj config` command, allowing users to leverage their preferred visual diffing applications for a more interactive review experience. The `--tool` option explicitly invokes a named tool.

HISTORY

`jj-diff` is an intrinsic command of the Jujutsu (jj) version control system, which was initiated by Martin von Loewis in the early 2020s. Jujutsu aims to be a modern, user-friendly, and powerful alternative to existing version control systems like Git, addressing common pain points with a focus on a more coherent data model and command set. `jj-diff` was designed from the outset to seamlessly integrate with `jj`'s unique concepts, such as the explicit 'working copy commit' and mutable portions of history, providing a more intuitive and consistent way to view changes compared to traditional VCS diff tools. Its evolution is tied directly to the ongoing development of the `jj` project itself, continuously enhancing its capabilities and external tool integrations.

SEE ALSO

jj(1), jj-log(1), jj-status(1), diff(1), git-diff(1)

Copied to clipboard