.gitignore generator: ignore the right files for your project
Tick your languages and tools to get a .gitignore that keeps build files and secrets out of Git.
A .gitignore file tells Git which files to leave alone, such as node_modules, build folders and secret .env files. Tick what you use, copy the result into a file named .gitignore at the top of your project.
Create your config file
Type your own values. The file below updates as you type, and nothing you type leaves your browser.
# Node.js
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
dist/
build/
.next/
.nuxt/
coverage/
*.tsbuildinfo
# Secrets (keep a .env.example instead)
.env
.env.*
!.env.example
# Logs
*.log
logs/
# macOS
.DS_Store
._*
# Windows
Thumbs.db
ehthumbs.db
Desktop.ini
# VS Code
.vscode/How this setup works
Step-by-step setup
- Create a file named .gitignore (with the dot, no extension) in the top folder of your project.
- Paste the lines above into it and save.
- Check what Git sees: git status. Ignored files no longer appear.
- Commit it: git add .gitignore, then git commit -m "Add gitignore".
- If a file was already committed, stop tracking it: git rm -r --cached folder-name, then commit.
What the important lines mean
- A line ending in / matches a folder, like node_modules/.
- * is a wildcard, so *.log matches every file ending in .log.
- A line starting with ! makes an exception, so !.env.example keeps that file.
- A line starting with # is a comment.
Common errors and how to fix them
- A file is still tracked after I added it to .gitignore
- .gitignore only affects files Git does not know yet. Run git rm --cached file-name (add -r for a folder), then commit.
- My .gitignore does not work at all
- Check the file is named exactly .gitignore, sits in the project folder, and has no hidden .txt on the end. Windows can add one.
- git check-ignore -v file-name
- This command shows which line of which .gitignore file matches. Use it to find out why a file is ignored or not.
- I committed a secret by mistake
- Adding it to .gitignore now does not remove it from history. Change the secret straight away, then remove the file from history with a tool such as git filter-repo.
Frequently asked questions
- What does .gitignore do?
- It tells Git not to track files that match its patterns, so build output, dependencies and secrets stay out of your repository.
- Where do I put the .gitignore file?
- In the top folder of your project. You can add more .gitignore files in subfolders for rules that apply only there.
- Should I ignore package-lock.json or composer.lock?
- No. Commit lock files for applications, so everyone installs the same versions.
More developer configs
- .editorconfig fileMake every editor on your team use the same indent, line endings and encoding.
- GitHub Actions workflow for Node.jsA ci.yml file that installs, lints, builds and tests your Node.js project on GitHub.
- package.json fileCreate a package.json with the right name, version, module type, scripts and Node version.
- tsconfig.json fileCreate a tsconfig.json for a Node or browser TypeScript project, with strict mode, target and output folder.
- SSH config for multiple GitHub accountsUse two or three GitHub accounts on one computer with separate SSH keys and host names.
- SSH config fileGive servers short names and choose the right key for each.