Docs / CLI

CLI reference

Invoked as git-treeline, git treeline, or gtl. All three are equivalent.

Setup

install

One command to get a developer productive. Creates .treeline.yml if missing, creates user config, installs the post-checkout hook, allocates ports, writes env, and optionally enables the local HTTPS router. Safe to re-run — every step is idempotent. Recommended over the separate initsetup flow.

init
--project--template-db--skip-agent-config

Generate .treeline.yml with self-documenting template. Auto-detects framework, writes AGENTS.md section, detects editor. Project name is derived from git remote get-url origin (basename, .git stripped) and sanitized to a valid identifier — a fitter-app repo lands as fitter_app. Warns when config/database.yml has a non-identifier database name.

rename <new-name>

Rename a project everywhere it appears: .treeline.yml, the registry, and user-config keys (port reservations, editor themes and colors, including project/branch variants). Drops the old worktree databases and re-runs setup so each worktree comes back up under the new name with a freshly cloned DB. Names must match [a-zA-Z_][a-zA-Z0-9_]* (Postgres identifier rules); the command suggests a sanitized form when given an invalid name.

new <branch>
--base--path--start--open--force--dry-run

Create worktree + allocate resources + run setup in one step. --start boots the app after setup. --open opens in browser. Works without a .treeline.yml: detects framework and prompts to init for server projects, or creates a plain worktree for non-server projects. Can be run from inside a worktree; prompts for confirmation unless --force is passed.

review <PR#>
--path--start--open

Fetch a GitHub PR into a new worktree with full setup. Requires gh CLI. From inside a worktree, prompts to switch the current worktree to the PR branch.

switch <branch-or-PR#>
--setup--restart

Switch a worktree to a different branch or PR. Fetches, checks out, updates registry, refreshes env. --setup re-runs setup commands. --restart bounces the supervised server.

setup [path]
--main-repo--dry-run

Full provisioning: allocate ports, copy files, write env, clone DB, run setup commands. Idempotent. When reusing an allocation, verifies ports are still free and valid; if not, re-allocates and warns.

refresh
--dry-run--force

Re-allocate all worktrees with current config and reservations. Restarts supervised servers automatically.

reallocate [paths...]
--from--all-registry--force

Bulk re-runs setup across many worktrees. Three modes: explicit paths, --from <dir> to scan a Conductor-style layout, or --all-registry for every entry whose directory still exists. Defaults to dry-run; pass --force to apply.

registry validate

Read-only audit of the worktree registry. Reports orphans (entries pointing at directories that no longer exist) and other inconsistencies without changing anything.

registry repair

Safe automatic repair: prunes orphaned entries after writing a backup of the previous registry. Pair with registry validate first.

registry forget <path>

Remove a single registry entry without freeing resources. For tooling integrations that need a surgical edit when release is too heavy.

release [path]
--drop-db--remove-worktree--project--all--force--dry-run

Free allocated resources. --drop-db removes the cloned database. --remove-worktree deletes the directory. --all releases everything. Warns on unpushed commits.

prune
--stale--merged--drop-db--remove-worktree--force

Clean orphaned allocations. --stale: worktrees whose directory no longer exists (distinguishes worktrees from standalone clones, so Conductor-style layouts aren’t pruned by mistake). --merged: branches merged to merge_target.

clone <repo>

Clone, detect framework, generate .treeline.yml if missing, run setup. Does not auto-start.

Server management

start
--with <hooks>--await--await-timeout

Fresh start (no supervisor): runs start hooks, syncs env, refreshes editor, launches supervisor. Resume (supervisor alive): sends start signal. No env sync, no hooks. --await blocks until TCP accepts on the port. On graceful exit, post_stop hooks run in reverse.

stop
--kill

Stop the server process. Supervisor stays alive for resume with gtl start. --kill shuts down the supervisor entirely instead of keeping it alive.

restart

Sync env, push updated vars to supervisor, restart server. Warns if commands.start differs from what the supervisor is running.

port
--json

Print allocated port for the current worktree. For agents and scripts.

open

Open in browser: HTTPS branch URL when gtl serve is running, else http://localhost:{port}.

routes
--json

Print the routing URLs for all allocated ports. Shows HTTPS URLs via the router when running, otherwise localhost fallback. Also shows the tunnel URL if configured.

Networking

See Networking guide for architecture and design rationale.

serve install

Generate CA, trust it, add port forwarding (443 → router), register background service. Also upgrades an existing router. Details

serve status

Show router state, CA status, port forwarding, and all active routes. Reads pf state from the kernel rather than pf.conf on disk, so “active” means actually loaded.

serve restart
--if-installed

Fast bounce of the running router via launchctl kickstart -k (macOS) or systemctl --user restart (Linux). No sudo, no plist rewrite. Use after upgrading the CLI to pick up the new binary. --if-installed exits 0 silently when no router service is registered — safe for tooling and brew post_install.

serve reload-pf

Targeted pfctl reload for the port-forwarding rules only. Use after a reboot dropped pf without paying the cost of a full serve install. (Most users won’t need this — v0.40.1 installs a LaunchDaemon that re-applies rules at boot.)

serve alias <name> [port]

Register a custom hostname on the router. From a worktree directory, port is auto-detected from the allocation. --remove <name> to unregister. Hot-reloaded within 5 seconds.

serve uninstall

Remove service, port forwarding, and CA trust.

serve hosts sync

Write entries for all active routes to /etc/hosts. Required for Safari on macOS with localhost domain.

serve hosts clean

Remove managed entries from /etc/hosts.

proxy <port> [target]
--tls

Bind a well-known port and forward to the current worktree. Target defaults to the first allocated port. Details

tunnel [port]
--domain--tunnel

Public HTTPS via Cloudflare. Subcommands: tunnel setup for named configs, tunnel status for connection state, tunnel default to set the active tunnel, tunnel remove to delete. Concurrent invocations on the same named tunnel multiplex through a lazy-start per-tunnel daemon, so multiple worktrees can share one cloudflared with merged multi-host ingress.

share [port]
--tunnel--tailscale

Ephemeral share URL (token-gated Cloudflare or --tailscale for tailnet-only). Torn down on Ctrl+C.

Cross-worktree

resolve <project> [branch]
--json

Look up another project's base URL from the registry. Same-branch default; optional explicit branch.

link <project> <branch>
--json

Override {resolve:project} to a fixed branch. Regenerates env and restarts server. gtl link lists links.

unlink <project>

Remove a link override.

Environment & database

env show
--json--template

Print env file. Treeline-managed keys marked [treeline]. --template shows unresolved tokens. gtl env defaults to show.

env sync

Re-read env from .treeline.yml, update env file, refresh editor.

db name
--json

Print the worktree's database name.

db reset
--from <db>

Drop and re-clone from template. --from overrides the source.

db restore <file>

Drop and restore from a pg_dump file. Auto-detects format.

db drop

Drop the worktree's database without re-cloning.

Navigation & status

status
--project--json--check--watch--interval

Show all allocations. --check probes ports. --watch auto-refreshes. --json for structured output.

dashboard

Interactive TUI (Bubble Tea). Browse worktrees by project with live updates. Aliases: gtl dash, gtl ui.

worktrees

Interactive TUI picker. Arrow keys to navigate, Enter to print path. Alias: gtl wt.

where <branch>

Print filesystem path to a worktree by branch. project/branch to disambiguate.

worktree

Print the filesystem path of the current worktree. For scripting and agent tooling.

doctor
--json--fix

Check config, allocation, runtime, and framework diagnostics. Verifies the listener PID against launchd’s registered PID, probes /_treeline/health, reads pf state from the kernel, and surfaces a Request-flow section that walks the chain end-to-end and points at the first failure. --fix auto-runs the remediations the doctor was already printing as hints (router restart, pf reload, registry prune for orphans).

Config & editor

config list

Dump all user-level settings.

config get <key>

Read a setting by dot-notation key.

config set <key> <value>

Write a setting and persist to disk.

config path

Print config file location.

config edit

Open config in $EDITOR.

editor refresh

Re-apply editor title, color, and theme for the current worktree.

completion bash|zsh|fish|powershell

Print shell completion script. Includes dynamic completions for config keys and project names.

Agent integration

mcp

Start the MCP server (stdio transport). Used by editors, not invoked directly. See MCP setup.

mcp-config

Print the JSON config block for adding the Git Treeline MCP server to your editor. Supports --cursor, --vscode, --zed, and --windsurf.

version

Print version.

Related

Back to docs