Gitignore Generator

Free .gitignore generator. Pick your stack (Node.js, Next.js, Laravel, WordPress, Python, Go and 35+ more), combine templates, add your own rules, then copy or download the file.

How to use the gitignore generator

  1. Pick a stack to start from, or select templates one by one: your language and framework, your operating system and your editor.
  2. Add your own rules in the text box, one pattern per line, like /uploads/ or *.sqlite.
  3. Copy or download the result and save it as .gitignore in the root of your repository.

When templates overlap, a rule that’s already in the file isn’t repeated. If your browser saves the download as gitignore or gitignore.txt, rename it to .gitignore.

What is a .gitignore file?

A .gitignore file tells Git which files and folders to leave out of version control: dependencies you can reinstall (node_modules, vendor), build output, logs, editor settings, operating system clutter like .DS_Store, and above all secrets like .env files. It’s a plain text file with one pattern per line, usually in the root of the repository. For the everyday Git commands around it, see the Git cheat sheet.

.gitignore pattern syntax

Pattern Matches
*.log Every file ending in .log, in any folder
node_modules/ Any folder called node_modules (the trailing slash means folders only)
/dist Only dist in the repository root (a leading slash anchors it)
docs/*.pdf PDFs directly inside docs, not in its subfolders
**/temp temp anywhere in the tree
!.env.example Re-includes a file an earlier rule ignored
# comment A comment

Rules are read from top to bottom and the last matching one wins, which is why ! rules come after the rule they override. A ! rule can’t bring back a file whose parent folder is excluded.

Stop tracking a file that's already committed

.gitignore only affects untracked files. If you committed node_modules or an .env file before adding the rule, remove it from the index; the file stays on your disk. If a secret was ever pushed, rotate it: it’s still in the history.

bash
# One file
git rm --cached .env

# A folder
git rm -r --cached node_modules

git commit -m "Stop tracking ignored files"

A global .gitignore for your machine

Files created by your OS or editor (.DS_Store, .idea/, *.swp) can go into one global file instead of every project. Generate it here with just the operating system and editor templates.

bash
git config --global core.excludesFile ~/.gitignore_global

Check why a file is ignored

git check-ignore -v prints the file, line and pattern that ignores a path. Handy when a file refuses to show up in git status.

bash
git check-ignore -v path/to/file
# .gitignore:3:*.log	path/to/file

FAQ

Where do I put the .gitignore file?

In the root of the repository, next to the .git folder. You can add more .gitignore files in subfolders; their patterns are relative to that folder.

Should I commit package-lock.json, composer.lock or yarn.lock?

Yes. Lock files make every install use the exact same dependency versions, so they belong in the repository. None of the templates here ignore them.

Should .gitignore itself be committed?

Yes. Commit it so everyone on the team ignores the same files.

Why is my .gitignore not working?

Usually because the file was committed before the rule existed; remove it from the index with git rm --cached. Also check that the file is named exactly .gitignore (not .gitignore.txt) and that the pattern’s leading or trailing slash means what you think.

Should I ignore .env files?

Always. Commit a .env.example with the variable names and fake values instead; the Env & secrets template does exactly that.

Did you like this tool? Share it with your friends:
Want to learn more? Ask your AI: