Notes | Git Ignore Reference
Git supports multiple ignore mechanisms for different scopes. Choose the appropriate one based on whether the rule should apply to a single repository, all repositories, or only the local working copy.
| Type | Scope | Tracked | Typical Use |
|---|---|---|---|
.gitignore | Repository | Yes | Ignore project-specific files that should be shared with all contributors. |
.git/info/exclude | Local repository | No | Ignore local files without modifying the repository. |
| Global excludes file | All repositories | No | Ignore personal files and directories across every Git repository. |
Repository .gitignore
Create or edit:
<repository>/.gitignore
Example:
node_modules/
*.log
dist/
Repository Local Exclude
Create or edit:
<repository>/.git/info/exclude
Example:
memos/
.local/
Global Excludes File
Configure once:
git config --global core.excludesfile ~/.gitignore_global
Create or edit:
~/.gitignore_global
Example:
.DS_Store
Thumbs.db
memos/
*.bak
Verify Ignore Rules
Check which rule matches a path:
git check-ignore -v <path>
Notes
- Ignore rules apply only to untracked files.
- Stop tracking an already tracked file before an ignore rule can take effect:
git rm --cached <path>