[BUG] Claude Code Creates ~/.config/git/ignore Without Permission
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?
Bug Report: Claude Code Creates ~/.config/git/ignore Without Permission
Summary
Claude Code v2.0.26 automatically creates ~/.config/git/ignore to globally exclude .claude/settings.local.json without asking for user permission. This modifies global git configuration outside of Claude Code's own directories.
Environment
- Claude Code Version: 2.0.26
- Operating System: Debian Linux 6.12.38+deb13-amd64
- Git Version: 2.47.3
- Installation Method: npm/nvm (Node v22.17.1)
Impact
User Impact
- Configuration Conflict: Creates confusion when users have existing
core.excludesfilesettings - Unexpected Behavior: Global git ignore behavior changes without user awareness
- File Precedence Issues:
~/.config/git/ignoreis checked by git even whencore.excludesfilepoints elsewhere - Trust Violation: Modifying global system configuration without permission
Technical Impact
Git checks both locations:
~/.config/git/ignore(XDG config, created by Claude Code)- The file specified in
core.excludesfile(user's choice)
This can lead to unexpected ignore behavior across all git repositories on the system.
Suggested Fix
Option 1: Use Project-Level Gitignore (Recommended)
Create .claude/.gitignore in Claude Code's own directory containing:
settings.local.json
Option 2: Respect Existing Configuration
- Check if
core.excludesfileis set - If set, append to that file (with permission)
- If not set, ask user permission before creating global ignore file
Option 3: Document and Provide Control
- Add a setting to control this behavior
- Document this in the setup/onboarding process
- Allow users to opt-out
Additional Context
The pattern **/.claude/settings.local.json is valid and useful for preventing accidental commits of local settings. However, the method of implementation (silent global git configuration modification) is problematic.
Workaround
Users can:
- Delete
~/.config/git/ignore - Add
**/.claude/settings.local.jsonto their own global gitignore file - Set up file monitoring to detect if Claude Code recreates it
Related Files
- Created:
~/.config/git/ignore - Referenced in code: Settings for
settings.local.jsonthroughout Claude Code - User's existing config:
~/.gitignore(or customcore.excludesfile)
Request
Please consider one of the suggested fixes above, prioritizing user consent and configuration transparency. Development tools should respect existing user configurations and request permission before modifying global system settings.
What Should Happen?
Expected Behavior
Claude Code should:
- Respect the user's existing
core.excludesfileconfiguration - Ask permission before modifying global git settings
- Use project-level
.gitignorefiles (e.g.,.claude/.gitignore) instead of global configuration - Document this behavior if it's intentional
Error Messages/Logs
## Evidence
### Audit Log Evidence
Using Linux audit subsystem, I captured the exact moment the file was created:
time->Wed Oct 22 14:57:29 2025
type=PROCTITLE msg=audit(1761137849.122:139187): proctitle="claude"
type=PATH msg=audit(1761137849.122:139187): item=1 name="/home/serge/.config/git/ignore" nametype=CREATE
type=SYSCALL msg=audit(1761137849.122:139187): comm="claude" exe="/home/serge/.nvm/versions/node/v22.17.1/bin/node"
type=CWD msg=audit(1761137849.122:139187): cwd="/home/serge/src/autops/wharf/ADR"
### File Details
$ stat ~/.config/git/ignore
File: /home/serge/.config/git/ignore
Size: 31
Modify: 2025-10-22 14:57:29.122870542 +0200
Birth: 2025-10-22 14:57:29.122870542 +0200
$ cat ~/.config/git/ignore
**/.claude/settings.local.json
### Existing Git Configuration
$ git config --global --get core.excludesfile
~/.gitignore
The user already has a global excludes file configured, but Claude Code ignores this setting and creates its own file in the XDG config location.
Steps to Reproduce
Steps to Reproduce
- Install Claude Code v2.0.26
- Run Claude Code in any git repository
- Check for the existence of
~/.config/git/ignore
Expected Behavior
Claude Code should:
- Respect the user's existing
core.excludesfileconfiguration - Ask permission before modifying global git settings
- Use project-level
.gitignorefiles (e.g.,.claude/.gitignore) instead of global configuration - Document this behavior if it's intentional
Actual Behavior
Claude Code automatically creates ~/.config/git/ignore containing:
**/.claude/settings.local.json
This file is created without warning or consent, potentially conflicting with existing git exclude configurations.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.26 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
_No response_
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗