`gco`: Your Brain Shouldn't Track What Git Already Knows

Amy Sillman, Split

Amy Sillman, Split

Split workflows create mental state. After enough context switches, you stop carrying it.

I hit fatal: 'fix/my-branch' is already used by worktree at '/path/to/worktree' about four times a day. I know exactly what it means. I know exactly where to go. I keep typing git checkout anyway.

I've been using git worktrees heavily since switching to agentic coding with Claude. A worktree lets you check out a branch into a separate directory without cloning the repo again, same git history, isolated working tree. Each branch Claude works on gets its own directory, no stomping on active work. The branches I'm touching myself get regular checkout.

Split workflows create mental state. After enough context switches, you stop carrying it.

The fix is eleven lines of shell. Add it to your .zshrc or .bashrcgco is a drop-in for git checkout. It wraps git checkout, lets it run, and if it fails with a worktree conflict, pulls the path straight out of git's error message and cds you there.

worktree_path=$(echo "$output" | sed -n "s/.*worktree at '\([^']*\)'.*/\1/p")

Git's error message is the API. The path you need is already in the output. Attempt, catch the specific failure, recover. Checkout succeeds, it passes through; anything else surfaces the original error.

gco.sh on GitHub Gist