claude-code - 💡(How to fix) Fix [Bug] Claude overwrites uncommitted changes when creating PR [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49696Fetched 2026-04-17 08:34:00
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×5commented ×1cross-referenced ×1

Error Message

[{"error":"Error: Failed to create shell snapshot: Command failed: C:\Program Files\Git\bin\bash.exe -c -l SNAPSHOT_FILE='C:\Users\Omid Rajabi\.claude\shell-snapshots\snapshot-bash-1776396391260-qe9355.sh'\n source "C:\Users\Omid Rajabi\.bashrc" < /dev/null\n\n # First, create/clear the snapshot file\n echo "# Snapshot file" >| "$SNAPSHOT_FILE"\n\n # When this file is sourced, we first unalias to avoid conflicts\n # This is necessary because aliases get "frozen" inside function definitions at definition time,\n # which can cause unexpected behavior when functions use commands that conflict with aliases\n echo "# Unset all aliases to avoid conflicts with functions" >> "$SNAPSHOT_FILE"\n echo "unalias -a 2>/dev/null || true" >> "$SNAPSHOT_FILE"\n\n \n echo "# Functions" >> "$SNAPSHOT_FILE"\n\n # Force autoload all functions first\n declare -f > /dev/null 2>&1\n\n # Now get user function names - filter completion functions (single underscore prefix)\n # but keep double-underscore helpers (e.g. __zsh_like_cd from mise, __pyenv_init)\n declare -F | cut -d' ' -f3 | grep -vE '^[^]' | while read func; do\n # Encode the function to base64, preserving all special characters\n encoded_func=$(declare -f "$func" | base64 )\n # Write the function definition to the snapshot\n echo "eval \"\$(echo '$encoded_func' | base64 -d)\" > /dev/null 2>&1" >> "$SNAPSHOT_FILE"\n done\n \n echo "# Shell Options" >> "$SNAPSHOT_FILE"\n shopt -p | head -n 1000 >> "$SNAPSHOT_FILE"\n set -o | grep "on" | awk '{print "set -o " $1}' | head -n 1000 >> "$SNAPSHOT_FILE"\n echo "shopt -s expand_aliases" >> "$SNAPSHOT_FILE"\n \n echo "# Aliases" >> "$SNAPSHOT_FILE"\n # Filter out winpty aliases on Windows to avoid "stdin is not a tty" errors\n # Git Bash automatically creates aliases like "alias node='winpty node.exe'" for\n # programs that need Win32 Console in mintty, but winpty fails when there's no TTY\n if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then\n alias | grep -v "='winpty " | sed 's/^alias //g' | sed 's/^/alias -- /' | head -n 1000 >> "$SNAPSHOT_FILE"\n else\n alias | sed 's/^alias //g' | sed 's/^/alias -- /' | head -n 1000 >> "$SNAPSHOT_FILE"\n fi\n \n\n \n # Check for rg availability\n echo "# Check for rg availability" >> "$SNAPSHOT_FILE"\n echo "if ! (unalias rg 2>/dev/null; command -v rg) >/dev/null 2>&1; then" >> "$SNAPSHOT_FILE"\n \n cat >> "$SNAPSHOT_FILE" << 'RIPGREP_FUNC_END'\n function rg {\n local _cc_bin="${CLAUDE_CODE_EXECPATH:-}"\n [[ -x $_cc_bin ]] || _cc_bin=$(command -v claude 2>/dev/null)\n if [[ ! -x $_cc_bin ]]; then command rg "$@"; return; fi\n if [[ -n $ZSH_VERSION ]]; then\n ARGV0=rg "$_cc_bin" "$@"\n elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "win32" ]]; then\n ARGV0=rg "$_cc_bin" "$@"\n elif [[ $BASHPID != $$ ]]; then\n exec -a rg "$_cc_bin" "$@"\n else\n (exec -a rg "$_cc_bin" "$@")\n fi\n}\nRIPGREP_FUNC_END\n \n echo "fi" >> "$SNAPSHOT_FILE"\n \n\n # Add PATH to the file\n cat >> "$SNAPSHOT_FILE" << 'PATH_END_e3y725zw4eu'\nexport PATH='/c/Users/Omid Rajabi/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Omid Rajabi/bin:/c/Program Files/PowerShell/7:/c/Users/Omid Rajabi/AppData/Local/Programs/Microsoft VS Code:/c/Python314/Scripts:/c/Python314:/c/tools/ruby34/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS…

Root Cause

Errors

[{"error":"Error: Failed to create shell snapshot: Command failed: C:\\Program Files\\Git\\bin\\bash.exe -c -l SNAPSHOT_FILE='C:\\Users\\Omid Rajabi\\.claude\\shell-snapshots\\snapshot-bash-1776396391260-qe9355.sh'\n      source \"C:\\Users\\Omid Rajabi\\.bashrc\" < /dev/null\n\n      # First, create/clear the snapshot file\n      echo \"# Snapshot file\" >| \"$SNAPSHOT_FILE\"\n\n      # When this file is sourced, we first unalias to avoid conflicts\n      # This is necessary because aliases get \"frozen\" inside function definitions at definition time,\n      # which can cause unexpected behavior when functions use commands that conflict with aliases\n      echo \"# Unset all aliases to avoid conflicts with functions\" >> \"$SNAPSHOT_FILE\"\n      echo \"unalias -a 2>/dev/null || true\" >> \"$SNAPSHOT_FILE\"\n\n      \n      echo \"# Functions\" >> \"$SNAPSHOT_FILE\"\n\n      # Force autoload all functions first\n      declare -f > /dev/null 2>&1\n\n      # Now get user function names - filter completion functions (single underscore prefix)\n      # but keep double-underscore helpers (e.g. __zsh_like_cd from mise, __pyenv_init)\n      declare -F | cut -d' ' -f3 | grep -vE '^_[^_]' | while read func; do\n        # Encode the function to base64, preserving all special characters\n        encoded_func=$(declare -f \"$func\" | base64 )\n        # Write the function definition to the snapshot\n        echo \"eval \\\"\\$(echo '$encoded_func' | base64 -d)\\\" > /dev/null 2>&1\" >> \"$SNAPSHOT_FILE\"\n      done\n    \n      echo \"# Shell Options\" >> \"$SNAPSHOT_FILE\"\n      shopt -p | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      set -o | grep \"on\" | awk '{print \"set -o \" $1}' | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      echo \"shopt -s expand_aliases\" >> \"$SNAPSHOT_FILE\"\n    \n      echo \"# Aliases\" >> \"$SNAPSHOT_FILE\"\n      # Filter out winpty aliases on Windows to avoid \"stdin is not a tty\" errors\n      # Git Bash automatically creates aliases like \"alias node='winpty node.exe'\" for\n      # programs that need Win32 Console in mintty, but winpty fails when there's no TTY\n      if [[ \"$OSTYPE\" == \"msys\" ]] || [[ \"$OSTYPE\" == \"cygwin\" ]]; then\n        alias | grep -v \"='winpty \" | sed 's/^alias //g' | sed 's/^/alias -- /' | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      else\n        alias | sed 's/^alias //g' | sed 's/^/alias -- /' | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      fi\n  \n\n      \n      # Check for rg availability\n      echo \"# Check for rg availability\" >> \"$SNAPSHOT_FILE\"\n      echo \"if ! (unalias rg 2>/dev/null; command -v rg) >/dev/null 2>&1; then\" >> \"$SNAPSHOT_FILE\"\n  \n      cat >> \"$SNAPSHOT_FILE\" << 'RIPGREP_FUNC_END'\n  function rg {\n  local _cc_bin=\"${CLAUDE_CODE_EXECPATH:-}\"\n  [[ -x $_cc_bin ]] || _cc_bin=$(command -v claude 2>/dev/null)\n  if [[ ! -x $_cc_bin ]]; then command rg \"$@\"; return; fi\n  if [[ -n $ZSH_VERSION ]]; then\n    ARGV0=rg \"$_cc_bin\" \"$@\"\n  elif [[ \"$OSTYPE\" == \"msys\" ]] || [[ \"$OSTYPE\" == \"cygwin\" ]] || [[ \"$OSTYPE\" == \"win32\" ]]; then\n    ARGV0=rg \"$_cc_bin\" \"$@\"\n  elif [[ $BASHPID != $$ ]]; then\n    exec -a rg \"$_cc_bin\" \"$@\"\n  else\n    (exec -a rg \"$_cc_bin\" \"$@\")\n  fi\n}\nRIPGREP_FUNC_END\n    \n      echo \"fi\" >> \"$SNAPSHOT_FILE\"\n  \n\n      # Add PATH to the file\n      cat >> \"$SNAPSHOT_FILE\" << 'PATH_END_e3y725zw4eu'\nexport PATH='/c/Users/Omid Rajabi/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Omid Rajabi/bin:/c/Program Files/PowerShell/7:/c/Users/Omid Rajabi/AppData/Local/Programs/Microsoft VS Code:/c/Python314/Scripts:/c/Python314:/c/tools/ruby34/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS…

Code Example

[{"error":"Error: Failed to create shell snapshot: Command failed: C:\\Program Files\\Git\\bin\\bash.exe -c -l SNAPSHOT_FILE='C:\\Users\\Omid Rajabi\\.claude\\shell-snapshots\\snapshot-bash-1776396391260-qe9355.sh'\n      source \"C:\\Users\\Omid Rajabi\\.bashrc\" < /dev/null\n\n      # First, create/clear the snapshot file\n      echo \"# Snapshot file\" >| \"$SNAPSHOT_FILE\"\n\n      # When this file is sourced, we first unalias to avoid conflicts\n      # This is necessary because aliases get \"frozen\" inside function definitions at definition time,\n      # which can cause unexpected behavior when functions use commands that conflict with aliases\n      echo \"# Unset all aliases to avoid conflicts with functions\" >> \"$SNAPSHOT_FILE\"\n      echo \"unalias -a 2>/dev/null || true\" >> \"$SNAPSHOT_FILE\"\n\n      \n      echo \"# Functions\" >> \"$SNAPSHOT_FILE\"\n\n      # Force autoload all functions first\n      declare -f > /dev/null 2>&1\n\n      # Now get user function names - filter completion functions (single underscore prefix)\n      # but keep double-underscore helpers (e.g. __zsh_like_cd from mise, __pyenv_init)\n      declare -F | cut -d' ' -f3 | grep -vE '^_[^_]' | while read func; do\n        # Encode the function to base64, preserving all special characters\n        encoded_func=$(declare -f \"$func\" | base64 )\n        # Write the function definition to the snapshot\n        echo \"eval \\\"\\$(echo '$encoded_func' | base64 -d)\\\" > /dev/null 2>&1\" >> \"$SNAPSHOT_FILE\"\n      done\n    \n      echo \"# Shell Options\" >> \"$SNAPSHOT_FILE\"\n      shopt -p | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      set -o | grep \"on\" | awk '{print \"set -o \" $1}' | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      echo \"shopt -s expand_aliases\" >> \"$SNAPSHOT_FILE\"\n    \n      echo \"# Aliases\" >> \"$SNAPSHOT_FILE\"\n      # Filter out winpty aliases on Windows to avoid \"stdin is not a tty\" errors\n      # Git Bash automatically creates aliases like \"alias node='winpty node.exe'\" for\n      # programs that need Win32 Console in mintty, but winpty fails when there's no TTY\n      if [[ \"$OSTYPE\" == \"msys\" ]] || [[ \"$OSTYPE\" == \"cygwin\" ]]; then\n        alias | grep -v \"='winpty \" | sed 's/^alias //g' | sed 's/^/alias -- /' | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      else\n        alias | sed 's/^alias //g' | sed 's/^/alias -- /' | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      fi\n  \n\n      \n      # Check for rg availability\n      echo \"# Check for rg availability\" >> \"$SNAPSHOT_FILE\"\n      echo \"if ! (unalias rg 2>/dev/null; command -v rg) >/dev/null 2>&1; then\" >> \"$SNAPSHOT_FILE\"\n  \n      cat >> \"$SNAPSHOT_FILE\" << 'RIPGREP_FUNC_END'\n  function rg {\n  local _cc_bin=\"${CLAUDE_CODE_EXECPATH:-}\"\n  [[ -x $_cc_bin ]] || _cc_bin=$(command -v claude 2>/dev/null)\n  if [[ ! -x $_cc_bin ]]; then command rg \"$@\"; return; fi\n  if [[ -n $ZSH_VERSION ]]; then\n    ARGV0=rg \"$_cc_bin\" \"$@\"\n  elif [[ \"$OSTYPE\" == \"msys\" ]] || [[ \"$OSTYPE\" == \"cygwin\" ]] || [[ \"$OSTYPE\" == \"win32\" ]]; then\n    ARGV0=rg \"$_cc_bin\" \"$@\"\n  elif [[ $BASHPID != $$ ]]; then\n    exec -a rg \"$_cc_bin\" \"$@\"\n  else\n    (exec -a rg \"$_cc_bin\" \"$@\")\n  fi\n}\nRIPGREP_FUNC_END\n    \n      echo \"fi\" >> \"$SNAPSHOT_FILE\"\n  \n\n      # Add PATH to the file\n      cat >> \"$SNAPSHOT_FILE\" << 'PATH_END_e3y725zw4eu'\nexport PATH='/c/Users/Omid Rajabi/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Omid Rajabi/bin:/c/Program Files/PowerShell/7:/c/Users/Omid Rajabi/AppData/Local/Programs/Microsoft VS Code:/c/Python314/Scripts:/c/Python314:/c/tools/ruby34/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS
RAW_BUFFERClick to expand / collapse

Bug Description i gave claude a simple prompt to make a PR, and it just nuked all my changes. this never happened before, i now have an explicit claude.local.md git convention, your latest update made it dumber

Environment Info

  • Platform: win32
  • Terminal: vscode
  • Version: 2.1.112
  • Feedback ID: f801bda8-865f-4029-ad71-1f3b72e5a484

Errors

[{"error":"Error: Failed to create shell snapshot: Command failed: C:\\Program Files\\Git\\bin\\bash.exe -c -l SNAPSHOT_FILE='C:\\Users\\Omid Rajabi\\.claude\\shell-snapshots\\snapshot-bash-1776396391260-qe9355.sh'\n      source \"C:\\Users\\Omid Rajabi\\.bashrc\" < /dev/null\n\n      # First, create/clear the snapshot file\n      echo \"# Snapshot file\" >| \"$SNAPSHOT_FILE\"\n\n      # When this file is sourced, we first unalias to avoid conflicts\n      # This is necessary because aliases get \"frozen\" inside function definitions at definition time,\n      # which can cause unexpected behavior when functions use commands that conflict with aliases\n      echo \"# Unset all aliases to avoid conflicts with functions\" >> \"$SNAPSHOT_FILE\"\n      echo \"unalias -a 2>/dev/null || true\" >> \"$SNAPSHOT_FILE\"\n\n      \n      echo \"# Functions\" >> \"$SNAPSHOT_FILE\"\n\n      # Force autoload all functions first\n      declare -f > /dev/null 2>&1\n\n      # Now get user function names - filter completion functions (single underscore prefix)\n      # but keep double-underscore helpers (e.g. __zsh_like_cd from mise, __pyenv_init)\n      declare -F | cut -d' ' -f3 | grep -vE '^_[^_]' | while read func; do\n        # Encode the function to base64, preserving all special characters\n        encoded_func=$(declare -f \"$func\" | base64 )\n        # Write the function definition to the snapshot\n        echo \"eval \\\"\\$(echo '$encoded_func' | base64 -d)\\\" > /dev/null 2>&1\" >> \"$SNAPSHOT_FILE\"\n      done\n    \n      echo \"# Shell Options\" >> \"$SNAPSHOT_FILE\"\n      shopt -p | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      set -o | grep \"on\" | awk '{print \"set -o \" $1}' | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      echo \"shopt -s expand_aliases\" >> \"$SNAPSHOT_FILE\"\n    \n      echo \"# Aliases\" >> \"$SNAPSHOT_FILE\"\n      # Filter out winpty aliases on Windows to avoid \"stdin is not a tty\" errors\n      # Git Bash automatically creates aliases like \"alias node='winpty node.exe'\" for\n      # programs that need Win32 Console in mintty, but winpty fails when there's no TTY\n      if [[ \"$OSTYPE\" == \"msys\" ]] || [[ \"$OSTYPE\" == \"cygwin\" ]]; then\n        alias | grep -v \"='winpty \" | sed 's/^alias //g' | sed 's/^/alias -- /' | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      else\n        alias | sed 's/^alias //g' | sed 's/^/alias -- /' | head -n 1000 >> \"$SNAPSHOT_FILE\"\n      fi\n  \n\n      \n      # Check for rg availability\n      echo \"# Check for rg availability\" >> \"$SNAPSHOT_FILE\"\n      echo \"if ! (unalias rg 2>/dev/null; command -v rg) >/dev/null 2>&1; then\" >> \"$SNAPSHOT_FILE\"\n  \n      cat >> \"$SNAPSHOT_FILE\" << 'RIPGREP_FUNC_END'\n  function rg {\n  local _cc_bin=\"${CLAUDE_CODE_EXECPATH:-}\"\n  [[ -x $_cc_bin ]] || _cc_bin=$(command -v claude 2>/dev/null)\n  if [[ ! -x $_cc_bin ]]; then command rg \"$@\"; return; fi\n  if [[ -n $ZSH_VERSION ]]; then\n    ARGV0=rg \"$_cc_bin\" \"$@\"\n  elif [[ \"$OSTYPE\" == \"msys\" ]] || [[ \"$OSTYPE\" == \"cygwin\" ]] || [[ \"$OSTYPE\" == \"win32\" ]]; then\n    ARGV0=rg \"$_cc_bin\" \"$@\"\n  elif [[ $BASHPID != $$ ]]; then\n    exec -a rg \"$_cc_bin\" \"$@\"\n  else\n    (exec -a rg \"$_cc_bin\" \"$@\")\n  fi\n}\nRIPGREP_FUNC_END\n    \n      echo \"fi\" >> \"$SNAPSHOT_FILE\"\n  \n\n      # Add PATH to the file\n      cat >> \"$SNAPSHOT_FILE\" << 'PATH_END_e3y725zw4eu'\nexport PATH='/c/Users/Omid Rajabi/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Omid Rajabi/bin:/c/Program Files/PowerShell/7:/c/Users/Omid Rajabi/AppData/Local/Programs/Microsoft VS Code:/c/Python314/Scripts:/c/Python314:/c/tools/ruby34/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS…

Note: Content was truncated.

extent analysis

TL;DR

The issue is likely caused by a conflict between the claude tool and the Git Bash configuration, resulting in the loss of changes when creating a PR, and a potential workaround is to review and adjust the claude.local.md git convention and the shell snapshot creation process.

Guidance

  • Review the claude.local.md file to ensure it is correctly configured and does not interfere with the Git Bash setup.
  • Investigate the shell snapshot creation process, specifically the bash.exe command and the snapshot-bash script, to identify potential issues or conflicts.
  • Check the PATH environment variable to ensure it is correctly set and does not contain any duplicate or conflicting entries.
  • Consider temporarily disabling the claude tool or adjusting its configuration to see if it resolves the issue.

Example

No specific code snippet can be provided due to the truncated content, but reviewing the snapshot-bash script and the claude.local.md file for any potential issues or conflicts is recommended.

Notes

The issue description is incomplete, and the provided error message is truncated, which limits the ability to provide a more specific solution. Further investigation and debugging are necessary to determine the root cause of the issue.

Recommendation

Apply a workaround by reviewing and adjusting the claude.local.md git convention and the shell snapshot creation process, as the issue is likely caused by a configuration conflict.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING