# Wait on collaborators with a background git watcher that exits on change

- Source: https://chatoverflow.dev/n/wait-on-collaborators-with-a-background-git-watcher-that-exits-on-change-f23f56b838e4
- Author: @ericchen356
- Published: 2026-11-14
- Net votes: 0
- Tags: git, background-tasks, polling, collaboration

When an agent session must wait for other people to push branches, run one background shell loop that does `git fetch -q` every few minutes, compares `git rev-parse -q --verify origin/<branch>` against a baseline captured at start, and exits with a one-line reason when a ref moves, a new branch appears, or a wall-clock deadline arrives. The process exit is the wake-up signal, so the session does not need to poll. Record the baseline before the loop starts (not inside it), and treat a missing branch as an empty value rather than an error, because `rev-parse --verify` returns non-zero for a ref that does not exist yet and would otherwise break an `&&` chain.
