How to exclude specific files from git management without using .gitignore

How to exclude specific files from git management without using .gitignore

2026.02.04

This page has been translated by machine translation. View original

Since starting to use Claude Code, files like the .claude/ directory and CLAUDE.md are being generated. Sharing these across the team could improve work efficiency, but due to various circumstances, sharing isn't possible at this time.

However, adding them to .gitignore would affect the entire team. If you're the only one using Claude Code, it may not be appropriate to modify the team's .gitignore file.

This article introduces how to exclude specific files or directories from git management without using .gitignore.

Test Environment

  • macOS 15.7.3
  • git version 2.50.1 (Apple Git-155)

What is .git/info/exclude?

.git/info/exclude is an exclusion settings file specific to your local repository. You can write it in the same format as .gitignore, but since it isn't committed to the repository, you can manage your own exclusion settings.

Feature .gitignore .git/info/exclude
Scope Entire repository (team shared) Local only
Committed Yes No
Usage Project-wide exclusion settings Personal exclusion settings

Step 1: Edit .git/info/exclude

To append using the echo command:

echo ".claude/" >> .git/info/exclude

Or you can open the file directly with an editor and add your exclusions:

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~

.claude/

Step 2: Verify the exclusion settings

Run git status and confirm that the files or directories you excluded are no longer displayed.

Note

.git/info/exclude only works for files not yet tracked by git.
If you want to exclude files that have already been committed, you first need to remove them from the index using git rm --cached.

git rm --cached -r .claude/

Additional Info: Global Settings

If you want to exclude the same files in all repositories, you can use global settings:

git config --global core.excludesfile ~/.gitignore_global
echo ".claude/" >> ~/.gitignore_global

With this setting, .claude/ will be excluded in all repositories. However, because of its wide-ranging impact, I don't personally recommend this approach.

Summary

  • .git/info/exclude is a local-only exclusion settings file
  • You can set personal exclusions without changing the team's .gitignore
  • It's useful for managing personal environment-specific files like Claude Code configuration files

I hope this helps when you want to exclude personal files without cluttering the team's .gitignore.

Share this article

FacebookHatena blogX

Related articles