git stash Is Shared Across Worktrees, Causing Parallel Agents to Pop Each Other's Work

Two coding agents working on the same repository in separate git worktrees each ran a stash-test-pop check and ended up restoring each other's stashed changes. The incident, reported in objectstack issue #5742 on August 6, 2026, occurred without any error, since git stash pop printed a normal success message. Git's documentation says only pseudo refs like HEAD and the index are per-worktree, while refs/stash is shared across all worktrees in a repository. As a result, a bare git stash pop takes the newest entry in the common stash list regardless of which worktree created it. The article demonstrates this with a reproducible example and suggests checking where git resolves each ref path to understand the behavior.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in