LinuxCommandLibrary

jj-absorb

Absorb changes into parent commit

TLDR

Move all eligible and unambiguous changes from a revision to other revisions automatically

$ jj absorb [[-f|--from]] [revset] [[-t|--into]] [revsets]
copy

Move only changes in given files from a revision to other revisions
$ jj absorb [[-f|--from]] [revset] [[-t|--into]] [revsets] [filesets]
copy

SYNOPSIS

jj absorb [OPTIONS] [REVISIONS...]

PARAMETERS

[REVISIONS...]
    Optional. A list of target revisions to absorb changes into. If omitted, changes are absorbed into the current commit. Can be combined with `--from`.

--from
    Specifies the source commit(s) from which changes should be absorbed. If omitted, changes from the working copy are used.

--into
    Specifies the target commit(s) into which changes should be absorbed. If omitted, changes are absorbed into the current commit.

--all
    Absorb changes from all descendant commits of the target that also descend from the source.

--edit, -e
    Open an editor to modify the commit message of the target commit(s) and resolve conflicts.

--insert, -i
    If changes cannot be fully absorbed into existing commits, insert new commits as necessary.

--dry-run
    Perform a trial run without making any changes, showing what would happen.

--branch
    A comma-separated list of branch names to consider for the absorb operation's scope.

DESCRIPTION

jj absorb is a fundamental command in the Jujutsu (jj) version control system, designed to integrate modifications into existing commits. Unlike traditional version control systems where commits are immutable, jj allows for an "editable history." The `absorb` command facilitates this by taking uncommitted changes from the working copy and incorporating them into the current commit, or by moving changes from descendant commits (children) into their ancestors. This makes it incredibly powerful for refactoring history, iteratively developing features, and tidying up commit messages or content. It essentially acts as a flexible rebase or commit-amend operation, but with more fine-grained control over which changes go where in the commit graph. It's often used when you've made further edits related to a previous commit, or when you want to consolidate changes across several dependent commits.

CAVEATS

jj absorb rewrites history, creating new commits with new change IDs. This can lead to conflicts if not handled carefully, especially when collaborating or if changes are already pushed. Conflicts may require manual resolution using jj resolve or external merge tools.

INTERACTIVE REFINEMENT

jj absorb is excellent for iterative development. As you refine a feature, you can continuously absorb new changes back into the original commit, keeping your history clean and focused without needing to create many "fixup" commits.

CONFLICT RESOLUTION

If conflicts arise during absorption, jj will typically mark the repository as conflicted. You'll need to resolve these manually using jj resolve or external merge tools before completing the operation. The `--edit` flag can assist in this process.

HISTORY

Jujutsu (jj) is a relatively new distributed version control system, developed by Google, first publicly released around 2022. It aims to provide a more intuitive and powerful workflow for managing changes compared to traditional systems like Git, especially concerning history editing. jj-absorb is a core command reflecting jj's design philosophy of an "editable history." It was conceived as a fundamental operation to allow users to incrementally refine their work by moving changes between related commits without resorting to complex rebase interactions. Its development is intertwined with the evolution of jj itself, making it a central pillar of the system's workflow.

SEE ALSO

jj-commit(1), jj-squash(1), jj-fold(1), jj-rebase(1), jj-amend(1)

Copied to clipboard