Claude Code Git Bash on Windows: Diagnose Shell Selection and Cut-Off Commands

Diagnose Claude Code Git Bash on Windows with a read-only probe, verify which shell tool ran, and confirm when Claude Code ignored a Git Bash executable path.

Claude Code Git Bash probe illustrated as two terminal output slips. The direct wrapper prints three lines and the Bash tool slip has a missing GB_END line.Claude Code Git Bash probe illustrated as two terminal output slips. The direct wrapper prints three lines and the Bash tool slip has a missing GB_END line.
Illustrative task:git-bash-01. Compare the direct wrapper and Claude Code Bash results line by line. Based on the GNU Bash manual and Anthropic’s tools reference.

A Bash command prints its first line in Claude Code and then stops. You paste the same line into Git Bash and it runs to completion. Before editing the script, find out what actually ran. Claude Code Git Bash troubleshooting on Windows starts with three observations you can collect independently. Check whether the intended executable starts, which tool Claude called, and whether the submitted command produced its final output marker.

Use an existing native Windows Claude Code installation, Git for Windows, a Windows PowerShell terminal, and a disposable project you can open in the CLI. The worked case uses C:\Program Files\Git\bin\bash.exe and three lines you can compare by eye. You’ll finish with a checked launch path, a record of the tool and its output, and a way to verify whether a one-key configuration change cleared a rejection warning. The examples show illustrative expectations for your own runs.

Run the probe through the Git for Windows wrapper

  1. Open Windows PowerShell in the disposable project. Run claude --version and write down the complete output. Launch Claude Code from this window later so the version check and session refer to the same launch context.
  2. Run where.exe git to find candidate Git executables. The example assumes Git for Windows is installed under C:\Program Files\Git. If your intended installation lives elsewhere, locate its bin\bash.exe and substitute that absolute path throughout the example.
  3. Check the wrapper path with Test-Path, then call it explicitly. Run the lines separately so you can associate each observation with its command. If the path check returns False, find the intended installation and repeat the check before running the last line. Anthropic installation troubleshooting
claude --version
where.exe git
Test-Path 'C:\Program Files\Git\bin\bash.exe'
& 'C:\Program Files\Git\bin\bash.exe' -c "builtin echo GB_BEGIN; builtin echo CASE_01; builtin echo GB_END"

For the example installation, the path check should print True. The final command should produce three lines in this order.

GB_BEGIN
CASE_01
GB_END

Test-Path checks the supplied path. The next command establishes whether Windows can invoke the wrapper and Bash can run the payload. An existing path can still fail at launch. Preserve the Windows error if that happens and resolve the direct launch before investigating Claude Code’s Bash tool. If where.exe git finds no match and the absolute wrapper invocation works, you already have a usable baseline. If the lookup returns several paths, record the one installation whose wrapper you actually tested. Anthropic installation troubleshooting

The PowerShell call operator & invokes the quoted path. PowerShell passes -c and the quoted command string as separate arguments. Bash reads and executes the string supplied to -c, then exits. The string contains no variables for the outer PowerShell to expand, so the same payload is easy to copy into Claude Code. Keep the straight quotes when copying. If PowerShell merely displays the executable path, check that the invocation starts with &. Microsoft PowerShell operators · GNU Bash invocation

Git for Windows documents bin\bash.exe as a wrapper. It prepares variables including PATH and MSYSTEM and spawns the Bash executable under usr\bin. The desktop git-bash.exe launcher is a separate entry point. Even if your desktop shortcut opens Git Bash, run the explicit wrapper invocation to verify the exact executable you can configure in Claude Code. Git for Windows wrapper documentation

Git for Windows documentation headed What is the Git wrapper?
Git for Windows project documentation introducing the Git wrapper and the installation’s entry points. · Original source

The probe itself asks Bash to print three fixed strings. builtin echo calls Bash’s own echo, which writes its argument and a newline. The payload opens no project files, reaches no network endpoints, and has no external command lookups. CASE_01 identifies this probe in your notes. Record all three lines as output from the current invocation, since the copied command and any previous run also contain the marker text. GNU Bash builtins

Compare the Bash and PowerShell tool results

  1. From the same PowerShell window, start a fresh interactive session with claude in the same project. Keep the session’s existing permissions. If you see a permission prompt, check the proposed tool and command against the example before approving that call. Claude Code advanced setup
  2. Paste the Bash request below as a regular chat message. Inspect the tool call and its result in the session. Record the tool name, submitted command, marker lines, and any error or status shown.
  3. If the session offers PowerShell as well, submit the separate PowerShell request. Save its result under the PowerShell tool name so each observation stays attached to the call that produced it.
Use the Bash tool for one foreground call. Run exactly this one-line command. If Bash is unavailable, report that and stop. Do not substitute another tool or run any other command.

builtin echo GB_BEGIN; builtin echo CASE_01; builtin echo GB_END

Read the result of the Bash call. The same three lines should appear as in the direct baseline. If Claude rephrased the code, invoked a nested shell, or split it into multiple calls, repeat with the original request and use a call that contains the exact command. Three calls that each print one line change the test because the Bash tool runs each command in a separate process. Anthropic also documents that Claude Code starts a non-interactive shell and applies aliases, functions, and shell options captured from shell configuration. Matching the command string keeps the payload controlled while both routes retain their own startup behavior. Claude Code tools reference

Use the PowerShell tool for one foreground call. Run exactly the expression below. If PowerShell is unavailable, report that and stop. Do not substitute another tool or run any other command.

'PS_PROBE_' + 'CASE_01'

Expect one line reading PS_PROBE_CASE_01 in the PowerShell result. Microsoft documents + as string concatenation for these operands. Anthropic documents PowerShell as the primary shell when the tool is enabled on Windows. With Git Bash installed, the Bash tool can also handle POSIX commands. Windows PowerShell is the terminal you used to launch claude in both cases. In the session, the actual tool name identifies which route handled the request, while the distinct output indicates that the PowerShell expression was evaluated. Microsoft PowerShell operators · Claude Code tools reference

The PowerShell row applies when that tool is available. With Git for Windows installed, Anthropic says the PowerShell tool is on by default for claude.ai and Console accounts and can be enabled for the documented cloud provider sessions. Keep the existing shell availability settings for this comparison. If there is a PowerShell result and no Bash call, the PowerShell observation answers only which tool ran. If a Bash request keeps producing no Bash call, check Git Bash discovery and any applicable shell permission rules before trying to explain absent markers. Claude Code advanced setup · Claude Code tools reference

The filled record uses an illustrative native Windows installation with Claude Code 2.1.337. Its last row shows how to record an incomplete result if one occurs. In your own notes put the CLI version next to each session’s result, especially if you relaunch during the comparison.

Input Action Expected result
task:git-bash-01 · native CLI 2.1.337 · wrapper at C:\Program Files\Git\bin\bash.exe In Windows PowerShell run claude --version, check the wrapper with Test-Path, and invoke it with -c and the exact three-statement payload above. 2.1.337 (Claude Code) and True for this setup. Direct wrapper output is GB_BEGIN, CASE_01, GB_END, each on its own line.
task:git-bash-01 · same directory and CLI · exact Bash payload Submit the Bash request in the interactive session started with claude and read the tool result. Tool Bash. Exact output lines are GB_BEGIN, CASE_01, GB_END.
task:git-bash-01 · same session · PowerShell available Request one PowerShell call with 'PS_PROBE_' + 'CASE_01'. Tool PowerShell. Exact output is PS_PROBE_CASE_01.
task:git-bash-01 · illustrative incomplete Bash result · same payload Compare the tool input to the baseline and inspect the result for the end marker and any error, cancellation, or timeout. GB_BEGIN and CASE_01 are visible. GB_END is absent. Record the missing marker and the actual status before assigning a cause.

Illustrative output matrix shows the first, middle and last lines for the direct wrapper and two possible Bash tool results.Illustrative output matrix shows the first, middle and last lines for the direct wrapper and two possible Bash tool results.
Illustrative output matrix for task:git-bash-01. A missing GB_END leaves completion unverified. Sources: GNU Bash manual and Anthropic tools reference, consulted December 4, 2026.

Confirm whether Claude Code ignored the Bash path

  1. In the Claude Code session, run /status to see which settings sources are active. Inspect the file holding CLAUDE_CODE_GIT_BASH_PATH. In the worked case the key is in the user’s ~/.claude/settings.json. Save the original value and note its file. If the key was absent, record that so you know to remove the added key when restoring the configuration. Claude Code configuration diagnostics
  2. If the existing value points to the desktop launcher or a missing file, close the session and run claude --debug from the same terminal and project. Inspect that launch’s debug log for CLAUDE_CODE_GIT_BASH_PATH and a warning about the rejected path. If the Bash tool is available, run the same Bash request and retain the result next to the warning.
  3. Change only the Bash path value to the verified wrapper. Start another claude --debug session from the same project and repeat the Bash request. Check the new log for the earlier rejection warning and compare the three marker lines in the new tool result. Anthropic installation troubleshooting

If there are already entries in the env object, add or replace the single key inside it. Use the following as the complete file contents only when the example needs no other settings.

{
  "env": {
    "CLAUDE_CODE_GIT_BASH_PATH": "C:\\Program Files\\Git\\bin\\bash.exe"
  }
}

The doubled backslashes belong to JSON string syntax. The decoded value contains the same single backslashes as the path in the PowerShell command. If the edit introduces a syntax error, run claude doctor from the terminal to check for invalid settings and fix the file before repeating the comparison. Check /status again in the fresh session. The command lists active settings sources, so inspect those files for competing values. For example, a corresponding key in .claude/settings.local.json can override a value in project or user settings. Claude Code advanced setup · Claude Code configuration diagnostics

Claude Code Git Bash override diagram branches from the saved path to a wrapper candidate or an auto-detection attempt with a debug warning.Claude Code Git Bash override diagram branches from the saved path to a wrapper candidate or an auto-detection attempt with a debug warning.
The debug warning identifies the rejected override even when auto-detection finds a working Git Bash. Source: Anthropic installation troubleshooting.

An illustrative before value is C:\Program Files\Git\git-bash.exe. The file can exist and still fail the filename check. Anthropic documents bash.exe, sh.exe, bash, and sh as the accepted override filenames. From v2.1.219, a nonexistent path or unsupported filename causes Claude Code to ignore the variable and try auto-detection, logging a warning visible with --debug. Auto-detection checks the default Git installation locations first, then looks for Git on PATH and uses that installation’s bin\bash.exe. Before v2.1.219, Claude Code could accept an existing file regardless of name and would exit at startup when the configured path did not exist. Anthropic installation troubleshooting

In the worked case, both the rejected launcher and the corrected wrapper are under the default Git installation. Auto-detection can find that wrapper even while Claude Code ignores the old setting. If both calls print GB_END, compare the debug logs for the rejected filename. If the corrected log explicitly identifies the path used, record it. Otherwise, record the observations you have: the old rejection warning cleared and Bash printed all three lines. The selected executable path remains unconfirmed by that log.

If the warning persists, compare the reported path with the exact value you saved. A warning that still names git-bash.exe after you changed the user file gives you a concrete value to look for in active local, project, or managed configuration. Also check whether the launch environment already supplies the variable. A warning naming the intended bin\bash.exe calls for another direct Test-Path and -c check against that precise value. If an existing, correctly named path still fails and the result shows an endpoint protection block, take the executable path and the exact error to your IT team. Claude Code configuration diagnostics · Anthropic installation troubleshooting

For more on tracing a competing value, see Claude Code Environment Variables.

Investigate a Bash result that stops before GB_END

  1. Confirm that the call was Bash and that the submitted input contains all three builtin echo statements. If the final statement is already missing in the input, correct the request and inspect the next call. You have found a difference before shell execution.
  2. Read the tool result through its last line. If the command was denied, cancelled, timed out, or moved to the background, record that status alongside the marker lines. If GB_END appears in the tool result and the assistant’s reply omits it, record the tool result as complete for this probe.
  3. If the short probe passes and a longer read-only command still fails, compare that command’s exact input and actual result across the two routes. Use the same launch directory and the smallest command that retains the symptom. Check whether the discrepancy appears in the submitted input, the command result, or a preview of saved output.

A standalone GB_BEGIN in the command output shows that the shell reached the first echo. Seeing CASE_01 shows that it reached the middle statement. If GB_END is absent after those two lines, the output you can see leaves completion unverified. Look for an error or interruption and include its exact wording in the record. If no markers appear at all, start with the earliest visible problem, such as a refusal before execution or a shell error before the first print. A result can include both marker output and an error, so preserve both when they occur together.

This probe emits very little output. If a real build or test command produces far more text, check for a preview and saved output path before treating a missing line as an execution failure. Anthropic documents that sufficiently large successful Bash results can arrive as a preview with a saved output path and that large failures can arrive as an excerpt. A result reporting a move to the background includes a task ID and an output path. Wait for the background result before making the comparison, and record the timeout notice with it if that was what triggered the move. Claude Code tools reference

Anthropic’s December 4, 2026 notes for v2.1.337 document a fix for long Git Bash commands being cut short on Windows on Bedrock, Vertex, Foundry, gateway sign-ins, and with telemetry off. Use that note when the symptom, version, and existing configuration fit. The release notes leave the failing command length unspecified. The short probe can pass even where a longer command fails. If you already have a safe longer command that reproduces the symptom, preserve its exact text and compare across versions with the other launch conditions held steady. Anthropic’s v2.1.337 release notes

For version changes, follow the instructions for your installed distribution. How to Update Claude Code by Install Method

If the comparison succeeds in the standalone CLI and fails in a VS Code session, identify which surface produced each result. If the prompt fails before any shell call with an API error, troubleshoot that connection first. Claude Code VS Code Extension vs the Terminal CLI · Diagnose a Failed Claude Code Prompt With Claude Doctor

Restore the prior setting and rerun the comparison

  1. Close the diagnostic session. In the file you edited, restore the exact original value or remove only the added key if it was absent. If you created the file for this experiment, remove it only if it still contains just the diagnostic change.
  2. Rerun the direct wrapper command from the same project and record claude --version again. Start a fresh claude --debug session for the restored configuration, run the same Bash request, and compare the warning and output with the earlier runs. Then close the debug session and use ordinary claude for regular work.
  3. Decide whether to keep the verified wrapper path. If the invalid value produces a warning whenever it is effective and the corrected value clears it, keep the correction if you need to select that Git installation explicitly. If the key was originally absent and auto-detection already gives the intended behavior, the restored state may be sufficient.

In the worked case with git-bash.exe as the original value, restoring it should bring back the warning if the setting is still effective and the CLI uses the documented fallback behavior. The Bash probe may still complete with both values because the example wrapper is in a default location. If the warning stays gone, confirm the version, compare active settings, and verify that you are reading the log from the restored launch. The direct wrapper result remains the comparison point because it uses an explicit executable and bypasses Claude Code’s selection step. Anthropic installation troubleshooting

Here is an illustrative record for that outcome. “2.1.337. Direct wrapper printed all three lines. Before the edit, debug reported that the launcher path was ignored and Bash printed all three lines. After correction, the warning cleared and Bash again printed all three lines. Restoring the launcher path brought back the warning.” That record gives you a reason to correct the setting even though the probe completed before and after. If your output instead stops after CASE_01, preserve the exact input and tool status with the last visible line so another person can see where the observations diverged. You Can’t Replay What You Can’t See

Sources

Many assistants.
One place to remember.

Bring your AI sessions, context, and usage together with Automater.

Meet Automater