Worktree fetch leaves ssh reading keystrokes from the terminal

Status Open
Reported on v2.1.282
Maintainer reply None cached
Activity 0 comments · opened Sep 24, 2026

Bug

Creating a worktree for a subagent fetches the default branch from origin. With an SSH remote, ssh can prompt for a key passphrase or a host key on /dev/tty. git exits after a few seconds, but ssh keeps running in Claude Code's process group and consumes keystrokes. Typed letters disappear, and escape sequences arrive without their ESC, like [I[O[117;5u.

Fix

Set GIT_SSH_COMMAND='ssh -o BatchMode=yes' for the worktree fetch, and stop git's whole process group when it times out.

Reproduce

  1. In a repository with an SSH remote, make sure refs/remotes/origin/<default branch> exists, and delete .git/FETCH_HEAD.
  2. Start Claude Code with GIT_SSH_COMMAND='ssh -o UserKnownHostsFile=/tmp/empty -o StrictHostKeyChecking=ask'.
  3. Have it launch a subagent with isolation: "worktree".
  4. Type in the prompt.

Reproduced three out of three times. With "worktree": {"baseRef": "head"}, no fetch runs and input works.

Claude Code 2.1.282, Linux. Possibly related: #11391, #10375. Diagnosed with Claude Opus 5.5.

View original on GitHub ↗