LinuxCommandLibrary

jj-abandon

Delete Jujutsu changesets permanently

TLDR

Abandon revisions specified by given revsets (e.g. B::D, A..D, B|C|D, etc.)

$ jj abandon [revsets]
copy

Abandon revisions, without deleting their bookmarks and moving them to the parent revisions instead
$ jj abandon --retain-bookmarks [revsets]
copy

Abandon revisions, without modifying the contents of their children
$ jj abandon --restore-descendants [revsets]
copy

SYNOPSIS

jj abandon [OPTIONS] [REVISIONS...]

PARAMETERS

-r, --revisions ...
    Specifies the commit(s) to be abandoned. If omitted, the working copy's current commit is abandoned. Multiple revisions can be provided.

--no-abandon-working-copy
    Prevents the working-copy commit from being abandoned if it is among the specified revisions. Instead, a new working-copy commit will be created on a non-abandoned ancestor.

DESCRIPTION

jj abandon marks one or more commits as "abandoned." In Jujutsu, abandoned commits are conceptually removed from the visible history of a branch, making them unlisted by default in commands like jj log. However, the commit data itself is not immediately deleted from the repository. This non-destructive nature allows for later recovery if needed.

Abandoning is useful for cleaning up working history, removing experimental changes, or correcting mistakes without permanently losing the work. When a commit is abandoned, all its descendants are also implicitly abandoned, ensuring graph consistency. This command is often used to tidy up the commit graph, offering a unique approach compared to other version control systems.

CAVEATS

While commits are not physically deleted, they become invisible by default in most jj commands. Recovery requires knowing their commit hash, which can be challenging if not explicitly noted.
Abandoning a commit also implicitly abandons all its descendants, which can have cascading effects on your commit history.
There is no direct "undo" command for jj abandon. Recovery relies on commands like jj restore or jj new with the old commit ID.
Can affect concurrent work if others are building on the abandoned commits, as their history will no longer be visible by default.

RECOVERY OF ABANDONED COMMITS

Abandoned commits are not permanently deleted from the repository. They are tracked in the obsolescence log (viewable with jj obslog) and can be recovered by referring to their commit hash using commands like jj new <hash> or jj restore <hash>. This provides a safety net not easily available in other VCS systems after discarding changes.

IMPACT ON DESCENDANTS

When you abandon a commit, all its child commits (descendants) are also implicitly marked as abandoned. This ensures the consistency of the commit graph. If you intend to preserve certain descendants, you should typically use jj rebase to move them onto a different, non-abandoned parent before performing the abandon operation.

HISTORY

Jujutsu (jj) is a relatively new version control system designed to address some pain points of Git, particularly around mutable history and commit identification. jj abandon is a core operation reflecting jj's philosophy of making history explicit and manageable. Unlike Git's git reset --hard which discards commits (making them subject to garbage collection), jj abandon explicitly marks commits as obsolete but keeps their data accessible via the obslog and by hash, allowing for easier recovery and a more robust history model. Its development is ongoing as part of the jj project.

SEE ALSO

jj(1), jj log(1), jj restore(1), jj new(1), jj obslog(1), git-reset(1), git-rebase(1)

Copied to clipboard