Quick access

Saved in this browser. Sign in to keep it on all your devices.

.gitignore Generator

Generate .gitignore files for your projects.

.gitignore Output
Version 1.1 Updated What's new

Release notes

  1. v1.1 Latest
    • Added an in-depth guide below the tool, written from what the tool actually does.
    • All 28 templates now add their full rules, and lock files stay tracked.

About the .gitignore Generator

A .gitignore file tells Git which files to leave out of version control, such as dependencies, build output, logs, and secrets like .env files.

How to use it

  1. 1 Choose your languages, frameworks, and editors.
  2. 2 Generate the combined file.
  3. 3 Save it as .gitignore in the root of your repository.

Frequently asked questions

Why is a file still tracked after I added it to .gitignore?

.gitignore only affects untracked files. Run git rm --cached <file> to stop tracking a file that was already committed.

Should .env be in .gitignore?

Yes. .env files hold secrets and should never be committed. Commit a .env.example with placeholder values instead.

Can I have more than one .gitignore?

Yes. A .gitignore in a subfolder applies to that folder and everything below it.

Reading the patterns

*.log          any file ending in .log, at any depth
build/         a folder called build, at any depth
/config.php    only config.php in the repository root
docs/**/*.pdf  PDFs anywhere under docs
!keep.log      an exception to an earlier rule
# note         a comment

A leading slash anchors a pattern to the folder holding the .gitignore. A slash in the middle anchors it too, so src/temp matches only that exact path, while temp alone matches at any depth.

Rule order and exceptions

Git reads the file from top to bottom, and the last matching rule wins. That is why !.env.example must come after .env.*, and the Node template here writes them in that order.

An exception cannot rescue a file whose parent folder is excluded, since Git does not look inside an ignored folder at all. To keep one file in logs/, write logs/* in place of logs/, then add !logs/keep.txt.

Lock files should be committed

Files such as package-lock.json, yarn.lock, composer.lock and Cargo.lock record the exact dependency versions that were tested. Committing them means your teammates and your deployment install the same code you ran. The templates here leave them out for that reason.

The VS Code template shows a middle path for editor settings. It ignores the folder’s contents but keeps settings.json, extensions.json and launch.json so a team can share them.

Personal rules belong elsewhere

Your editor’s swap files and your operating system’s clutter are specific to you, so they do not have to live in every repository. Create one global file and register it with this command:

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

When a rule seems to have no effect, ask Git directly. Running git check-ignore -v path/to/file prints the exact file and line responsible, and prints nothing if no rule matches.

If a secret was already committed

Adding a file to .gitignore does not remove it from past commits. Anyone with access to the repository’s history can still read it. Treat an exposed key as compromised: revoke it and issue a new one first, then clean the history with a tool like git filter-repo if you need to.