Gitignore Generator

Tick what your project uses and get one clean .gitignore, with each part under its own heading and no pattern listed twice.

How it works

The page carries a small set of templates for common languages, frameworks, editors and operating systems. Each one lists the files people most often commit by mistake for that stack: dependency folders, build output, caches, local secrets and editor clutter.

When you tick several, they are joined in the order you chose, each under a "# Name" heading. A pattern that an earlier template already wrote is left out of the later one, so Node and Next.js together do not list node_modules/ twice. Your own lines go last, under "# Your own".

The templates are bundled with the page. Nothing is fetched from GitHub or anywhere else, so it works offline and nobody learns what your project is made of.

How to use it

  1. 1 Tick the boxes that fit your project under Language, Framework, Editor and System.
  2. 2 Add anything specific to your project in Your own lines, one pattern per line.
  3. 3 Check the .gitignore preview.
  4. 4 Copy it, or download it and save it as .gitignore in the root of your repository.

Good to know

  • Some browsers save the download as "gitignore" without the dot, because files starting with a dot are hidden. Rename it to .gitignore.
  • .gitignore only affects files git is not tracking yet. To stop tracking a file you already committed, run git rm --cached <file> and commit.
  • A pattern ending in / matches directories only. build/ ignores a build folder but not a file named build.
  • A line starting with ! puts back something an earlier line ignored, but only if its parent folder is not ignored.
  • Editor and OS clutter (.DS_Store, .idea/) can also go in a global ignore file: git config --global core.excludesFile ~/.gitignore_global.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

A Node project on a Mac in VS Code: what each line of its .gitignore does

Tick Node, macOS and VS Code and this page writes three sections. The Node section starts with node_modules/, the folder npm fills with every dependency. It can hold hundreds of megabytes and is rebuilt from package.json and the lock file, so it never belongs in the repository. The trailing slash matters: it tells git to match only directories, so a stray file called node_modules would still be seen. The same goes for dist/, build/ and coverage/, which are produced by your tools and recreated on every build.

Next come .env, .env.* and !.env.example. The first two keep local settings files out, which is where API keys and database passwords usually live. The third line starts with !, which means "not ignored after all". Because .env.* matched .env.example, the ! line puts it back, so you can commit a template that shows which settings exist without their values. We checked this in a fresh repository: .env and .env.local were hidden from git status, and .env.example was listed as a new file.

The macOS section is short: .DS_Store, the hidden file Finder leaves in every folder it opens to remember icon positions, plus ._* and a few others the system creates on shared drives. None of them are useful to anyone else. The VS Code section shows a subtlety worth knowing. It ignores .vscode/* and then puts back .vscode/settings.json, tasks.json, launch.json and extensions.json, the files a team may want to share.

Why .vscode/* and not .vscode/? Because git cannot re-include a file whose parent folder is ignored. When a folder is ignored, git does not even look inside it, so the ! lines never get a chance to match. We tested this too. With .vscode/ followed by !.vscode/settings.json, git status showed nothing from the folder at all. With .vscode/* instead, settings.json appeared and the other files stayed hidden. The star ignores the folder’s contents, not the folder, and that leaves room for exceptions.

The page joins the sections in the order you ticked them and writes each pattern once. If you add Next.js to this project, its node_modules/, .env and *.tsbuildinfo lines are skipped because Node already wrote them, and only the new ones, such as .next/ and .vercel/, appear under its heading. Other templates use glob features you will see in the wild: Python’s *.py[cod] matches .pyc, .pyo and .pyd files with one line, and ** matches any number of folders.

One rule catches nearly everyone. .gitignore decides what git will start tracking, not what it already tracks. If node_modules or a .env file was committed before the ignore line existed, it stays in the repository and keeps showing changes. Run git rm -r --cached node_modules (or the file name), commit, and the ignore rule takes over from there. If a secret was committed, also change the secret: it is still in the history.

Frequently asked questions

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

Because git is already tracking it. .gitignore only stops untracked files from being added. Run git rm --cached on the file (add -r for a folder), commit, and from then on it stays ignored.

Where do I put the .gitignore file?

In the top folder of the repository, next to the .git folder. Patterns are read relative to the file’s own folder, and you can add more .gitignore files in subfolders if you need to.

Why does my "!" line not bring the file back?

Git cannot re-include a file if a folder above it is ignored, because it never looks inside that folder. Ignore the folder’s contents (.vscode/*) rather than the folder (.vscode/), then the ! lines work.

Is this the same as the github/gitignore templates?

No. These are shorter templates written for this site, covering the files that actually get committed by accident. The GitHub collection is much longer and covers many tools most projects never use. Add anything missing in Your own lines.

Should I ignore my lock file?

Usually not. Applications should commit package-lock.json, poetry.lock, go.sum or Cargo.lock so every install gets the same versions. The Rust template notes the one common exception, libraries that leave Cargo.lock out.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.