Gitignore generator
What is a Gitignore Generator?
A .gitignore file tells Git which files to leave out of version control: dependencies, build output, logs, editor settings, operating system clutter and, most importantly, secrets. This generator combines curated templates for your languages, frameworks, editors and operating systems into one clean, de-duplicated file.
How to use it
- Select the templates that match your stack, for example Node, VS Code and macOS.
- Review the combined output.
- Save it as
.gitignorein the root of your repository and commit it.
Example output (excerpt)
# Node
node_modules/
dist/
npm-debug.log*
.env
# macOS
.DS_Store
# VS Code
.vscode/*
!.vscode/extensions.jsonPattern syntax
*.logignores all files ending in .log.build/ignores a directory anywhere in the tree./config.local.jsonwith a leading slash only matches at the repository root.!keep.logre-includes a file excluded by an earlier pattern.**/tempmatches temp at any depth.
Common mistakes
- Already tracked files are not ignored. Run
git rm --cached fileto stop tracking a file that was committed earlier. - Committed secrets stay in history. Adding
.envto .gitignore later does not remove it from old commits; rotate the leaked keys. - Personal editor files can also go in your global ignore file (
core.excludesFile) instead of every project. - Lock files such as package-lock.json should usually be committed, not ignored.
Frequently Asked Questions
Why is a file still tracked after adding it to .gitignore?
gitignore only affects untracked files. Run git rm --cached on the file and commit to stop tracking it.
Should I ignore package-lock.json?
No. Lock files should be committed so everyone installs the same dependency versions.
Where does the .gitignore file go?
Usually in the repository root, but you can add more in subdirectories for local rules.
How do I ignore files on my machine only?
Use .git/info/exclude for one repository, or a global ignore file configured with core.excludesFile.