Claude Code Hang on certain git commands

Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 6 comments · opened Feb 26, 2025 · closed Mar 3, 2025
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Bug Description
Claude code hangs if a git command times out, at least from inside a docker container. Example:

Bash(git status)…
  ⎿  On branch main
     Your branch is ahead of 'origin/main' by 2 commits.
       (use "git push" to publish your local commits)

     Changes not staged for commit:
       (use "git add <file>..." to update what will be committed)
       (use "git restore <file>..." to discard changes in working directory)
     	modified:   ../prompts/Keap Base Prompt.txt
     	modified:   tandem/spectacular_schema.yaml

     Untracked files:
       (use "git add <file>..." to include in what will be committed)
     	../entrypoint.sh
     	test_api_call.py
     	test_api_call_no_id.py
     	test_company_creation.py
     	test_fixed_company_creation.py

     no changes added to commit (use "git add" and/or "git commit -a")

● Bash(git push origin main)…
  ⎿  Command execution timed out
     Exit code 143

● Let me try again with a shorter timeout:

● Bash(git push origin main)…

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Bash command                                                                                                                                                                          │
│                                                                                                                                                                                       │
│   git push origin main                                                                                                                                                                │
│   Uploads local main branch commits to remote repository                                                                                                                              │
│                                                                                                                                                                                       │
│ Do you want to proceed?                                                                                                                                                               │
│ ❯ Yes                                                                                                                                                                                 │
│   Yes, and don't ask again for git push commands in /app/tandem                                                                                                                       │
│   No, and tell Claude what to do differently (esc)                                                                                                                                    │
│

The UI is completely unresponsive at this point and the only fix is closing out of the terminal.

This happens with other git commands occasionally as well.

Environment Info

  • Platform: macos / Docker
  • Terminal: iTerm.app
  • Version: 0.2.14
  • Feedback ID: 9949e30d-5742-4bd4-bcbc-e1dc751af532

View original on GitHub ↗

6 Comments

bcherny collaborator · 1 year ago

This should be fixed in v0.2.18. Restart to get the update and lmk if it's feeling better.

jmaddington · 1 year ago

Related: if it were possible to _resume_ previous sessions that would be helpful, especially in the event of a crash/hang.

Jarred-Sumner · 1 year ago

@bcherny it consistently gets stuck in the bash tool, output:

⏺ Now, let me create a Vue plugin for Bun based on the examples and documentation I've reviewed:

  Bash(mkdir -p packages/bun-plugin-vue/src)…

∗ Percolating… (30s · esc to interrupt)

This is 0.2.19 (but has been consistent in each version I've tried). If I try to interrupt it, it prints:


> If I try to interrupt it
  ⎿  API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.14: Did not find 1 `tool_result` block(s) at the beginning of this message. Messages
following `tool_use` blocks must begin with a matching number of `tool_result` blocks."}}
jmaddington · 1 year ago

@bcherny it still hangs.

!Image

It tried to push twice, after the first one timed out it tried again, but still became unresponsive to keyboard input.

It looks like it is trying to read from interactive input, which I didn't expect:

!Image

bcherny collaborator · 1 year ago

@Jarred-Sumner would you mind adding a repro in https://github.com/anthropics/claude-code/issues/290? Specific tool name + transcript would be very helpful.

@jmaddington thanks for the report! Tracking in https://github.com/anthropics/claude-code/issues/292

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.