[BUG] Claude always using cd command into current working directory in combination with Git commands, requiring approval for whitelisted commands

Status Fixed / completed
Reported on v2.1.68
Maintainer reply ✓ Yes — claude[bot]
Activity 16 comments · opened Mar 4, 2026 · closed May 18, 2026
💡 Likely answer: A maintainer (claude[bot], contributor) responded on this thread — see the highlighted reply below.

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

All of Claude git commands uses cd combinaton like:

cd <current working directory> && git ...

So even though I have git commands like git diff etc in my alow list, they all require approval due to "Compound commands with cd and git require approval to prevent bare repository attacks" warning.

En earlier versions, Claude would not pointlessly use cd command with git.

What Should Happen?

cd to current working directory should not trigger warning. Claude should not pointlessly run cd commands to current directory.

Error Messages/Logs

Steps to Reproduce

Work in a git repo, ask Claude to fix some bug. Claude begins running git commands like diff/log etc.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.68 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

PowerShell

Additional Information

_No response_

View original on GitHub ↗

16 Comments

github-actions[bot] · 5 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/30524
  2. https://github.com/anthropics/claude-code/issues/28240
  3. https://github.com/anthropics/claude-code/issues/27803

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

enricoros · 5 months ago

Seems to have begun a week ago or so, and still it happens more than ever.

hughesadam87 · 5 months ago

This is a huge bug for me - I've tried:

  • Updated settings files
  • UPdating claude.md to never run compount cd + git commands (ie. I tell it to cd first then run git commands) - it ignores this

Yolo mode is the only workaround and our admins disabled it.

Platform windows

Kryptos-FR · 5 months ago

I tried also to tell Claude to not do compound commands and instead it is now inserting the working directory in git commands with the -c flags, which is even worse.

yurukusa · 5 months ago

This is now handled by a PreToolUse hook. npx cc-safe-setup installs a cd-git-allow hook that auto-approves cd + git compounds when the git operation is read-only (log, diff, status, branch, show). Destructive operations still require approval.

Source: cd-git-allow.sh

navs-github · 4 months ago

+1 still an issue, claude cds into the directory its already in every time

Kryptos-FR · 4 months ago

Interestingly it doesn't happen when Claude models are used from GitHub Copilot. So it really seems to be a tooling issue on Claude itself (notably VSC plugin) and not on the model.

hughesadam87 · 4 months ago
Interestingly it doesn't happen when Claude models are used from GitHub Copilot. So it really seems to be a tooling issue on Claude itself (notably VSC plugin) and not on the model.

I dont use VSC - just Claude Code in terminal and still have the issue

claude[bot] contributor · 3 months ago

This issue was fixed as of version 2.1.113.

jbartlett-p3 · 3 months ago
This issue was fixed as of version 2.1.113.

@claude: Wrong. I'm running version 2.1.152, and it's still happening.

stebu-emp · 3 months ago

@claude: I'm using 2.1.153 and still having this issue. It's extremely annoying and time consuming.

tylerhunt · 3 months ago

I ended up putting this into my CLAUDE.md to work around it:

- Use `git -C <path> <command>` instead of `cd <path> && git <command>`
jbartlett-p3 · 3 months ago
I ended up putting this into my CLAUDE.md to work around it: - Use git -C <path> <command> instead of cd <path> && git <command>

Doesn't work. Claude ignores instructions constantly.

GP4cK · 2 months ago

@claude issue is still happening in 2.1.186.

ulope · 1 month ago

Same issue happening on macOS with version v2.1.204

Notably my dev directory is symlinked from another location. This may cause path normalization to misinterpret where the correct directory is.

bigcakes · 1 month ago

I also hit this constantly on MacOS