[BUG] Claude edits .gitignore

Status Fixed / completed
Maintainer reply ✓ Yes — igorkofman
Activity 7 comments · opened May 2, 2025 · closed May 14, 2025
💡 Likely answer: A maintainer (igorkofman, collaborator) responded on this thread — see the highlighted reply below.

Environment

  • Claude CLI version: 0.2.100 (Claude Code)
  • Operating System: osx
  • Terminal: iTerm2

Bug Description

In a recent version from the last few days, Claude code started writing into .gitignore:

**/.claude/settings.local.json

The .gitignore file is checked in and shared with my team. Not everyone uses Claude code (unfortunately) so it's not appropriate to write developer-specific configuration into a shared file like .gitignore.

Expected Behavior

Ideally, the CLI would prompt me for permission before ignoring anything, and even with permission, it should only write into .git/info/exclude, which is a git config file that is not part of the repository.

Additional Context

Also, I added /.claude/ into my .git/info/exclude file, so these files are already ignored. I think the CLI is adding ignore patterns without checking whether they are necessary.

View original on GitHub ↗

7 Comments

vemv · 1 year ago

+1, polluting repos isn't quite nice.

The smartest possible behavior would be for Claude to check whether .claude/settings.local.json is already gitignored, which may be achieved by the user in a number of ways (e.g. local or global gitignores).

No AI is needed for determining this, it's simple git status inspection: run git status, if the settings file is absent, then no .gitignore write is needed.

Cheers - V

ncaq · 1 year ago

I have configured global git ignore settings for Claude Code as follows:

❯ cat .config/git/ignore
**/.claude/settings.local.json

I frequently improve and contribute to others' FLOSS projects.
Since maintainers may not be using Claude Code, I cannot go around modifying .gitignore settings in multiple repositories.
I would like an option to not add these settings if git ls-files indicates they are already ignored.
Even without that, if the configuration prevents automatic addition, that would be sufficient.
Having diffs generated every time I approve a tool is too bothersome.
However, I cannot return to a life without Claude Code.

asmeurer · 1 year ago

The correct solution here is whenever claude generates a .claude/ directory inside of a git repo, it should add a .claude/.gitignore which contains

*

This will cause git to ignore .claude without requiring checking in any files. This is a common pattern (you'll see the same thing in things like .mypy_cache and .ruff_cache).

At the same time, these files are still going to be cleaned whenever someone runs git clean. Wouldn't it make more sense to store these per-repo settings in ~/.claude?

igorkofman collaborator · 1 year ago

This should be fixed in todays build!

wolfmanstout · 1 year ago

I've always had to ignore settings.local.json files myself, despite regularly updating Claude and never fiddling with any global git or Claude settings. I'm running Claude on WSL. What mechanism is being used at this point to ignore these files?

wolfmanstout · 1 year ago

@igorkofman for the above question. I need to know what behavior is expected before I open a bug about this.

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.