Skip to content
flow

CLI & automationdrop

drop

Create, list and delete git worktrees with drop, including the interactive delete TUIs (drop -d and drop -dc) and its layered config.

View as Markdown
On this page

drop is Flow's worktree tool. It creates a git worktree on a fresh branch in one command, keeps every worktree it makes in one folder inside the repository, and cleans them up again from an interactive list that shows which ones are safe to delete. Flow uses the same code for new sessions on a fresh branch, for scheduled runs and for the Trash page, and ships drop as a command you can run yourself.

Install drop

drop is bundled with Flow. Put it on your PATH with Settings › Advanced › Command-line tools (or Install command-line tools… in the command palette), which links flow-cli, drop, ghx, gitx and sink into /usr/local/bin. A CLI tool page whose command starts with drop always runs the copy bundled with Flow, installed or not.

sh
drop --help
drop --version

Create a worktree

sh
drop                                  # interactive: pick a repo and a fork source
drop new ~/src/app -y                 # non-interactive, with the defaults
drop --from origin/main --branch fix-login
drop --track feature-x                # check an existing branch out directly
drop --detach v1.4.0                  # a detached worktree at a ref
cd "$(drop -y --print-path)"          # create one and cd into it

drop new is the default command, so drop [repo] [options] works too. Run bare drop in a terminal and it walks you through the choices; with -y, or with no terminal, it uses the defaults and asks nothing.

Which repository. --repo PATH or the first argument; else the repository you are in; else an interactive picker over your favorites (★), recent repositories (·) and the repositories one level under reposDir.

Where it goes. Each worktree is created at REPO/WORKTREE_DIR/BRANCH/REPO_NAME, with worktreeDir defaulting to .worktrees. drop adds that folder to the repository's .git/info/exclude, so it never shows up as untracked and no tracked file is edited.

The branch name. Unless you pass --branch, drop names the new branch PREFIXCITY-HASH: your branchPrefix, a city name not already used by another branch, and a random 5-character suffix (for example tw-padua-k3f9a). A prefix ending in / joins directly (h20/padua-k3f9a); any other prefix is joined with a single -.

Fork sources

You wantUse
A new branch off the default branchno flag: origin/DEFAULT fetched fresh, or the local default branch with --base local (or isolationBase: "local")
A new branch off a local branch--from BRANCH, or pick it interactively
A new branch off a remote branch--from origin/BRANCH
An existing branch checked out directly--track BRANCH
A detached checkout at any ref--detach REF

New options

OptionMeaning
--repo PATHThe repository to spawn from (default: the current one, or the picker).
--from REFFork a new branch off this ref (origin/main, main, feat-x).
--branch NAMEThe new branch's name (default: PREFIXCITY-HASH).
--track BRANCHCheck the existing branch out; no new branch.
--detach REFCreate a detached worktree pinned to the ref.
--prefix PUse this branch prefix for this run.
--base origin|localWhere the default fork comes from: origin (fetched) or the local default branch.
--worktree-dir DIRUse this container folder for this run.
--print-pathPrint only the new worktree's path.
--jsonMachine-readable output.
-y, --yesNon-interactive: use the defaults, no prompts.

List worktrees

sh
drop ls              # worktrees drop manages for the current repo
drop ls ~/src/app --json

Each line is the worktree's id, its branch (or detached@SHA) and its path. Only worktrees under the repository's worktreeDir are listed: the main checkout is not drop's.

Delete worktrees interactively

drop -d (or drop delete) opens a full-screen list of the worktrees drop manages. Inside a repository it covers that repository; run from anywhere else it sweeps your favorites, your recent repositories and the repositories under reposDir for worktrees.

Each row shows:

  • the number of files with local changes,
  • how far the branch is behind and ahead of the default branch (↓2 ↑0),
  • the branch's GitHub pull request when the gh CLI is available (#8 merged, #12 open),
  • and how long ago the worktree was last active.
KeyDoes
␣Select or deselect the row
aSelect all
mAdd every "even" worktree (nothing unmerged: its HEAD is already in the default branch)
sAdd every stale worktree (no local changes, no activity for the stale threshold)
rRefresh the list
⏎Delete the selected worktrees
qQuit

The list also refreshes itself every 10 minutes. Deleting removes each worktree and safely deletes its branch when the branch is merged. A worktree you select in the list is removed even with local changes, since you chose it.

Continuous mode

drop -dc (or drop -d --continuous) keeps the list open: after each deletion it prints what it deleted, then comes back to the list minus what was removed, re-scanning in the background, with a ✓ or ✗ notice in the header. Only q, Esc or Ctrl-C end it. It exits 0 when every deletion succeeded, 1 otherwise.

Tip: Flow's Trash page does the same job inside the app, across all your repositories. See Trash.

Delete without the list

OptionMeaning
--mergedDelete every even worktree, previewed per repository.
--stale [DAYS]Delete clean worktrees with no activity for DAYS days (default 5).
--days NThe stale threshold the list's s key uses.
--dry-runPreview only; delete nothing.
-y, --yesSkip the confirmation prompt.
--forceForce removal even when git refuses (a locked worktree, for example).
--jsonHeadless JSON on stdout; never opens the list. Alone, a full status inventory; with --merged or --stale, a preview of the targets; add -y to delete and print the results.

--merged and --stale never touch a worktree with local changes, or the worktree you are standing in.

sh
drop -d --stale 14 --dry-run          # what would go
drop -d --merged -y                   # delete every even worktree
drop -d --json                        # inventory for a script or agent

Remove specific worktrees

sh
drop rm padua-k3f9a                  # by id
drop rm ~/src/app/.worktrees/x/app   # or by path
drop rm a b c --json

drop rm takes one or more ids (from drop ls) or paths, and --repo PATH for another repository. A worktree with local changes needs --force, as with git worktree remove. An id that matches nothing is reported and the others still go. It exits 0 only when every target was removed. Bare drop rm in a terminal opens the delete list instead.

Configuration

drop reads three settings, from lowest to highest priority:

  1. built-in defaults
  2. your global file, ~/.config/drop/config.json
  3. the repository's checked-in .drop.json
  4. your own per-repository file, ~/.flow/repo_config/REPO/drop.json
  5. command-line flags
KeyDefaultMeaning
worktreeDir".worktrees"The folder, relative to the repository root, that holds drop's worktrees.
branchPrefix""The prefix of generated branch names, such as "tw-" or "h20/".
isolationBase"origin"Where a new branch forks from without --from: "origin" (fetched fresh) or "local".

Any of these files may carry an "!important" list that lifts its value above the usual order; see Settings scopes.

The global file also holds the picker's lists:

json
{
  "worktreeDir": ".worktrees",
  "branchPrefix": "tw-",
  "isolationBase": "origin",
  "reposDir": "/Users/you/src",
  "favorites": ["/Users/you/src/app"],
  "recents": [],
  "repos": {
    "/Users/you/src/legacy": { "branchPrefix": "h20/" }
  }
}
KeyMeaning
reposDirThe folder scanned one level deep for repositories (default ~/src).
favoritesRepositories pinned to the top of the picker.
recentsThe last 10 repositories you created a worktree in, newest first. drop keeps this list itself.
reposPer-repository overrides keyed by absolute path, applied on top of the global values.

drop rewrites this file on every run, so keep it valid JSON.

The config command

sh
drop config              # the global file, and the effective settings for the current repo
drop config --json
drop config path         # where the global file is
drop config favorite     # favorite the current repo (or pass a path)
drop config unfavorite ~/src/app

Limits

  • Pull request status in the delete list needs the gh CLI.
  • --merged and --stale skip worktrees with local changes; select those in the list if you mean to delete them.
  • A corrupt .drop.json is an error; a corrupt ~/.flow/repo_config/REPO/drop.json is skipped with a warning.
Sources

Written from these files in the Flow app repo

  • src/bin/drop.rs
  • src/drop/mod.rs
  • src/drop/args.rs
  • src/drop/config.rs
  • src/drop/naming.rs
  • src/drop/gitignore.rs
  • src/drop/status.rs
  • src/drop/commands/new.rs
  • src/drop/commands/ls.rs
  • src/drop/commands/rm.rs
  • src/drop/commands/delete.rs
  • src/drop/commands/tui.rs
  • src/drop/commands/config.rs
  • src/cli_tools.rs
  • docs/settings-scopes.md