Skip to main content
Git Configuration & Troubleshooting

Git Ignore Generator & Cache Fixer

Is your git ignore not working? Generate tailored templates for node gitignore, react gitignore, django gitignore, or clear tracked Git cache in seconds.

Fix: Why is Git Ignore Not Working?

If a file or directory (like git ignore node modules) was already committed or staged before adding it to .gitignore, Git continues tracking it! To clear the Git index cache and enforce your rules, run these terminal commands:

# 1. Untrack all cached files (does not delete local files)
git rm -r --cached .

# 2. Re-stage everything adhering to new .gitignore
git add .

# 3. Commit the cleaned index
git commit -m "fix: untrack files ignored by .gitignore"

Complete .gitignore Rule Syntax & Wildcard Reference

Understanding gitignore wildcards and pattern matching helps prevent sensitive API keys, build artifacts, and vendor binaries from ever polluting your Git repository.

Ignore a Directory & Subdirectories

How to git ignore a directory, git ignore folder and contents, or git ignore folder and subfolders:

# Trailing slash matches directory only
build/
# Matches all files in directory
logs/*
# Matches subdirectory anywhere in tree
**/temp/

Covers gitignore directory and subdirectories, gitignore all files in directory, and gitignore next folder.

Git Ignore Exception (!)

To create a git ignore exception or gitignore exception (e.g. gitignore everything except a specific file):

# Ignore all .log files
*.log
# But keep important.log
!important.log

Note: You cannot re-include a file if its parent directory is excluded.

Local Gitignore vs Git Global Ignore

Depending on your workflow scope, Git provides multiple levels of exclusion:

  • Repository .gitignore: Committed to the repository, sharing exclusions across all team members. You can have a root file or multiple gitignore files in each subdirectory gitignore (e.g., git ignore subdirectory).
  • Local gitignore (.git/info/exclude): Excludes private files only on your local machine without committing anything to remote repositories.
  • Git global ignore: Configured once across your entire computer using git config --global core.excludesfile ~/.gitignore_global for OS files like macos gitignore (.DS_Store) or IDE configs (vscode git ignore, visual studio git ignore, or gitignore visual studio).

Gitignore Comments and Wildcard Syntax

To document your rules, use standard gitignore comments starting with a hashtag symbol (#). A single asterisk git ignore wildcard (*) matches zero or more characters within a folder name, while double asterisks (**) span recursively across multiple folder levels.