Script against the worktree list in CI
internals & scripting
// what it does
--porcelain emits one attribute per line (worktree, HEAD, branch, plus bare/detached/locked/prunable flags) in a format guaranteed stable across Git versions — the contract for scripts that iterate worktrees, dashboards that watch agent fleets, or CI that cleans up stale checkouts. Add -z for NUL-terminated records that survive any path.
// shell
$ git worktree list --porcelain$ git worktree list --porcelain | awk '/^worktree /{print $2}'// gotcha
Never parse the default human output — column alignment and annotations shift between versions. And in the porcelain stream, boolean attributes like detached appear only when true, so don't expect a fixed number of lines per record.