How do I configure git to ignore some files locally?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Local-only ignore behavior in Git depends on whether the file is tracked. For untracked files that only you want to ignore, use .git/info/exclude; for tracked files with local modifications, the answer is different and comes with tradeoffs.
Ignore Untracked Files Only on Your Machine
If the file is not tracked and you do not want to commit an ignore rule to the repository, add the pattern to .git/info/exclude:
This file behaves a lot like .gitignore, but it is local to your clone and is not committed to the repository. It is the cleanest answer for developer-specific files such as local notes or machine-specific config files that should stay untracked.
Use a Global Ignore for Repeated Personal Patterns
If the same local patterns apply across many repositories, configure a global ignore file:
This is useful for editor temp files, OS metadata files, and other personal noise that should never show up in any repository.
Tracked Files Are Different
If the file is already tracked by Git, ignore files do not make Git forget changes to it. That is where many people get confused. For tracked files, you have a few options, none of them perfect:
- stop tracking the file and replace it with a template file committed to the repo
- use
git update-index --skip-worktree <file>for local divergence - use
git update-index --assume-unchanged <file>only with care
For example:
This tells Git to leave your local changes alone in many workflows, but it is not a permanent policy mechanism and can become confusing when the repository version changes later.
Prefer Repository Design Over Local Tricks
If many developers need local customization, the better repository design is usually:
- commit
config.example.json - ignore
config.json - generate or copy the local file during setup
That avoids relying on index flags that are easy to forget and hard for teammates to discover.
Know How to Undo Local Tracking Tricks
If you used skip-worktree or assume-unchanged, you should also know how to reverse it:
Without that, local ignore behavior can become mysterious months later when Git seems to stop noticing a file you expected it to track.
Use the Right Tool for the File State
A simple rule helps avoid confusion:
- untracked local file:
.git/info/exclude - personal noise across many repos: global ignore file
- tracked shared config problem: redesign the repository layout
That framing is more reliable than trying to force one ignore mechanism to solve every case.
Common Pitfalls
- Adding a tracked file to
.gitignoreand expecting Git to stop reporting its changes. Ignore rules mainly affect untracked files. - Using
skip-worktreeas if it were a team policy. It is only a local index hint. - Forgetting that
.git/info/excludeis local to one clone and will not help teammates. - Using
assume-unchangedfor actively edited files. It is easier to misuse than many people realize. - Solving a shared config problem with local hacks when the repository should really use template files and documented setup steps.
Summary
- For local untracked files, use
.git/info/exclude. - For personal patterns across many repositories, use a global ignore file.
- Ignore rules do not solve tracked-file changes.
- For tracked files,
skip-worktreeand similar flags are local workarounds, not ideal long-term design. - If local configuration is common, restructure the repository around template files instead of relying on hidden local state.

