Git offers three ways to ignore files beyond .gitignore

Original: .gitignore Isn't the only way to ignore files in Git

Why This Matters

Developers can better manage ignored files by leveraging appropriate ignore levels for shared, personal, and system-specific workflows.

Git provides three levels for ignoring files: .gitignore (shared), .git/info/exclude (per-repository), and ~/.config/git/ignore (global machine-level). Each serves different use cases for managing ignored files across repositories.

Git users typically rely on .gitignore to exclude files from version control, but two additional ignore mechanisms exist. The .gitignore file is the standard approach, checked into repositories and shared across teams. The .git/info/exclude file resides in each repository's .git directory without being checked in, making it ideal for personal, workflow-specific files like notes.txt that shouldn't be committed or shared. The ~/.config/git/ignore file applies globally across all repositories on a machine, useful for system-generated files like macOS's .DS_Store. Users can customize the global ignore file location using git config --global core.excludesFile command. To verify which ignore file is filtering a specific file, the git check-ignore -v command displays the source: repository .gitignore, .git/info/exclude, or global config file location and line number.

Source

nelson.cloud — Read original →