Claude Code repeatedly appends duplicate entries to ~/.config/git/ignore
Bug Description
Claude Code continuously appends the same ignore pattern to ~/.config/git/ignore, creating duplicate entries for **/.claude/settings.local.json. This happens repeatedly during normal usage, causing the file to grow with identical lines.
Environment Info
- Platform: darwin (macOS)
- OS Version: Darwin 24.6.0
- Claude Code Version: Latest
- Terminal: Various (affects all terminals)
Steps to Reproduce
- Use Claude Code in any project
- Check
~/.config/git/ignorefile - Notice multiple identical entries for
**/.claude/settings.local.json - Continue using Claude Code
- File grows with more duplicate entries
Expected Behavior
The ignore pattern **/.claude/settings.local.json should only appear once in the file, or Claude Code should check if the pattern already exists before adding it.
Actual Behavior
Multiple identical lines are appended to the file:
**/.claude/settings.local.json
**/.claude/settings.local.json
**/.claude/settings.local.json
Impact
- Cluttered git ignore configuration
- Potential conflicts with tools like chezmoi that manage dotfiles
- File grows unnecessarily over time
Related Issues
This issue is related to #5880, which reported the same problem but was incorrectly closed as a duplicate of #3523. The issues are fundamentally different:
- #3523: Hook configuration duplication in memory causing performance issues with multiple process executions
- #5880 & This issue: File-level duplication where identical text lines are repeatedly appended to
~/.config/git/ignore
As correctly noted by @speto in #5880, these represent distinct bugs with different root causes that require separate fixes.
Suggested Fix
Before appending to ~/.config/git/ignore, Claude Code should:
- Check if the pattern already exists in the file
- Only add the pattern if it's not already present
- Alternatively, use a more robust method to ensure the ignore pattern is present without duplication
Additional Context
This affects users of dotfiles management tools (like chezmoi) who track their global git configuration, as the repeated modifications create conflicts and require manual cleanup.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗