.gitignore

What is a .gitignore file?

Tells git which files to skip when staging, committing, or pushing — your build artefacts, secrets, and OS junk that shouldn't end up in version control.

Safe format
Type Code
By Linus Torvalds / Git Project
MIME text/plain

Drop any file to identify it

No upload. No signup. No sending your file halfway across the internet.
We tell you what it is, right here in your browser.

What is it

Every git repository has stuff that shouldn't be tracked. Build artefacts (`dist/`, `build/`), dependencies (`node_modules/`), local config (`.env`, `.vscode/settings.json`), OS junk (`.DS_Store`, `Thumbs.db`), and editor temporary files. The .gitignore file lists patterns for everything git should ignore — one pattern per line, glob-style.

The syntax is straightforward: `*.log` ignores all log files, `node_modules/` ignores the whole directory, `!important.log` re-includes a specific file. A leading slash anchors the pattern to the repo root; without it, the pattern matches at any depth. Comments start with `#`. The official rule reference lives in `git help gitignore`, and github.com/github/gitignore has language-specific templates you can drop into a fresh project.

The most common .gitignore mistake: editing the file after a file is already tracked. .gitignore only stops untracked files from being added — it doesn't retroactively untrack anything. If you've already committed `secrets.env`, you need `git rm --cached secrets.env` to remove it from the index, then commit. The file's git history still contains the secret, so rotate it immediately. Tools like git-filter-repo or BFG Repo-Cleaner can rewrite history if you really need the secret gone.

Technical details
Full Name
.gitignore
MIME Type
text/plain
Developer
Linus Torvalds / Git Project
Magic Bytes
N/A
Safety
.gitignore is a known, safe format.
What opens it
Any text editor
FREE All
VS Code
FREE All
FAQ
Why is my file still showing up in git status even though it's in .gitignore?
Because git is already tracking it. .gitignore only affects untracked files. To stop tracking a file that's been committed, run `git rm --cached path/to/file`, commit, and now .gitignore will keep it out going forward.
Where do I put rules I want for every repo on my machine?
Use a global gitignore. Run `git config --global core.excludesfile ~/.gitignore_global` and add patterns there. Useful for OS junk like .DS_Store and Thumbs.db that don't belong in any project's .gitignore.
Related formats