Skip to main content

Keep active work. Clear finished tasks.

Use sync to bring a task up to date. Use done for one finished worktree, or clean to review several candidates together.

Bring a task up to date​

gji sync

This fetches and rebases the current branch onto the configured default branch. Commit or otherwise resolve local changes before syncing. A rebase can require conflict resolution; use your normal Git workflow to continue or abort it.

For every worktree in the current repository:

gji sync --all

Detached worktrees are skipped. Set syncRemote and syncDefaultBranch in configuration when needed.

Finish one worktree​

Check that the worktree contains no files you still need:

gji status
gji done feature/search

done removes the linked worktree and attempts to remove its branch. To keep the branch and remove only the directory:

gji done feature/search --keep-branch

Interactive mode asks before discarding uncommitted changes or removing an unmerged branch. Read those prompts: uncommitted and untracked files removed with a worktree cannot be recovered through gji undo.

Review several worktrees for cleanup​

gji clean

The picker starts in the current repository. Press Tab to include all registered repositories. Each repository's primary worktree and your current worktree remain protected. Uninspectable repositories are reported rather than treated as empty.

To inspect the candidate removal plan without removing anything:

gji clean --stale --dry-run

--stale limits cleanup to clean branch worktrees whose upstream is gone and whose changes are already merged into the configured or remote default branch, including squash- or rebase-merged changes.

Limit cleanup to a location​

gji clean --path ~/worktrees/gji/spike
gji clean --path '../worktrees/*/experiment-*' --dry-run

A plain path matches that directory and its descendants. Glob patterns with *, **, or ? match the whole worktree path; quote them to prevent shell expansion. Escape a literal wildcard with a backslash, such as 'fix-\?-bug'. Repeat --path to match any of several patterns.

--path searches all registered repositories. In the picker, press Tab to narrow the scope back to the current repository.

Force removal only after reviewing the targets​

gji clean --stale --force
gji done feature/search --force

--force bypasses confirmation, can remove dirty worktrees, and can delete unmerged branches. It isn't just a quieter mode. Preview the cleanup plan and check the files you need before using it in automation.

Restore a journaled cleanup​

gji undo --list
gji undo
# Or restore a specific operation:
gji undo <id>

Undo restores recorded branch/worktree state from the operation journal and refuses to overwrite existing work. It does not restore uncommitted files, untracked files, dependency installs, or changes made by hooks.

When cleanup spans repositories, use the per-repository undo commands printed by the cleanup result. See the command reference for related commands.