Read the HEAD of another worktree from anywhere
internals & scripting
// what it does
Per-worktree refs (HEAD, refs/bisect/*, refs/worktree/*) are reachable from any worktree through special prefixes: worktrees/<id>/HEAD for a linked worktree and main-worktree/HEAD for the main one. That lets a supervisor script ask what commit every agent is sitting on without cd-ing into each directory.
// shell
$ git rev-parse worktrees/auth/HEAD$ git log -1 --oneline main-worktree/HEAD$ ls $(git rev-parse --git-common-dir)/worktrees// gotcha
<id> is the admin directory name under .git/worktrees — usually the path basename, possibly suffixed with a number when names collide. List the real ids with ls $(git rev-parse --git-common-dir)/worktrees rather than guessing.