Skip to content

git worktree-sync

Synchronize worktrees with remote (prune + update all)

TIP

This command is also available as daft sync. See daft sync.

Description

Synchronizes all worktrees with the remote in a single command.

This is equivalent to running daft prune followed by daft update --all:

  1. Prune: fetches with --prune, removes worktrees and branches for deleted remote branches, executes lifecycle hooks for each removal.
  2. Update: pulls all remaining worktrees from their remote tracking branches.
  3. Rebase (--rebase BRANCH): rebases all remaining worktrees onto BRANCH. Best-effort: conflicts are immediately aborted and reported.
  4. Push (--push): pushes all branches to their remote tracking branches. Branches without an upstream are skipped. Push failures are reported as warnings; they do not cause sync to fail. Use --force-with-lease with --push to force-push rebased branches.

If you are currently inside a worktree that gets pruned, the shell is redirected to a safe location (project root by default, or as configured via daft.prune.cdTarget).

For fine-grained control over either phase, use daft prune and daft update separately.

Usage

git worktree-sync [OPTIONS]

Options

OptionDescriptionDefault
-v, --verboseIncrease verbosity (-v for hook details, -vv for full sequential output)
-f, --prune-dirtyForce removal of worktrees with uncommitted changes
--forceHidden deprecated alias for --prune-dirty
--rebase <BRANCH>Rebase all branches onto BRANCH after updating
--autostashAutomatically stash and unstash uncommitted changes before/after rebase
--pushPush all branches to their remotes after syncing
--force-with-leaseUse --force-with-lease when pushing (requires --push)
--include <INCLUDE>Include additional branches in rebase/push (email, branch name, or 'unowned')
--stat <STAT>Statistics mode: summary or lines (default: from git config daft.sync.stat, or summary)
--columns <COLUMNS>Columns to display (comma-separated). Replace: branch,path,age. Modify defaults: +col,-col. Available: branch, path, size, base, changes, remote, age, annotation, owner, hash, last-commit
--sort <SORT>Sort order (comma-separated). +col ascending, -col descending. Columns: branch, path, size, base, changes, remote, age, owner, hash, activity, commit

Global Options

OptionDescription
-h, --helpPrint help information
-V, --versionPrint version information

See Also

Released under the MIT License.