Gitignore Generator

Combine .gitignore templates for your languages, frameworks, editors and operating system.

Gitignore Generator tool

Languages
Frameworks and platforms
Tools and project files
Editors and IDEs
Operating systems

Browsers save the file as gitignore.txt, because names that start with a dot are not allowed. Rename it to .gitignore in the root of your repository.

About the Gitignore Generator

Committing build folders, dependency directories, editor settings or secret .env files to a repository is a common and sometimes costly mistake. This gitignore generator combines ready-made rules for the languages, frameworks, editors and operating systems you use, such as Node.js, Python and VS Code on macOS, into one tidy file with commented sections and no duplicate lines. Remember that adding a rule does not remove files Git already tracks, so untrack those separately.

There are 45 templates, from Java, Go, Rust, C# and PHP to React, Next.js, Django, Laravel, Flutter, Unity and Terraform, plus editor files from JetBrains IDEs, Vim and Emacs and system clutter such as .DS_Store and Thumbs.db. Rules that appear in several templates are written only once, and you can add your own lines at the end.

A good .gitignore keeps build output, dependency folders, logs, caches and secrets such as .env files out of your repository. That keeps the history small and clean, avoids merge conflicts in generated files, and prevents passwords and API keys from being published by accident. Remember that ignoring a file does not remove it if Git already tracks it: run git rm --cached on it first.

Copy the result or download it, then save it as .gitignore in the root of your repository. For web server configuration, try the .htaccess generator, to password-protect a folder, the htpasswd generator, and to set file permissions, the chmod calculator.

How to use the Gitignore Generator

  1. Search or browseType a name such as node or python, or browse the groups of templates.
  2. Tick your stackSelect every language, framework, editor and operating system you use.
  3. Add custom rulesType extra patterns for files that are specific to your project.
  4. Save the fileCopy or download the result and save it as .gitignore in your repository root.

Gitignore Generator features

  • 45 templates in five groups
  • Languages, frameworks, editors and operating systems
  • Search to find templates fast
  • Duplicate rules removed automatically
  • Commented sections per template
  • Your own custom rules
  • Copy or download
  • Works in your browser, even offline

Common uses

  • Starting a new repository with the right ignore rules
  • Cleaning up a project that committed build output
  • Keeping .env files and keys out of Git
  • Standardizing setups across a team using different editors
  • Adding OS and editor rules to an existing file

Gitignore in practice: a leaked .env file, example settings files, global ignores, negation patterns and checking why a file is ignored

By the FreeToolsWorld editorial team · Updated November 2026 · How we write and check our guides

A .gitignore file is the first line of defence against committing passwords, build output and personal clutter to a repository. This guide starts with a mistake that happens every day, an environment file committed to a public repository, and explains what to do. It then covers committing example settings, keeping personal editor files out of shared ignore files, the negation patterns that trip people up, checking why a file is ignored and deciding what generated files belong in a repository.

A worked example: a leaked .env file

A developer pushes a Laravel project to a public repository and notices the .env file, holding the database password and a mail service key, was included. Deleting the file in a new commit is not enough, because it remains in the history, and automated bots scan public repositories for secrets within minutes of a push.

The right order is: first change every exposed password and key, so the leaked values become useless; then stop tracking the file with git rm --cached .env, add .env to .gitignore and commit. Removing the file from history with a tool such as git filter-repo is worthwhile afterwards, but rotating the secrets is what actually protects the system.

Example settings files

Commit a file such as .env.example containing every setting name with placeholder values, and ignore the real .env. New developers copy the example and fill in their own values, and the example documents which settings exist. Updating it whenever a new setting is added keeps new team members from guessing.

Personal ignores belong elsewhere

Files created by your own editor or operating system, such as .DS_Store, Thumbs.db or editor folders, can be ignored on your computer for every project using a global ignore file, set with git config --global core.excludesFile followed by the file's path. For ignores specific to one repository on one machine, the .git/info/exclude file works without changing the shared .gitignore.

Negation patterns

A pattern starting with an exclamation mark re-includes files, which is useful for keeping an empty folder in a repository: logs/* followed by !logs/.gitkeep ignores everything in logs except the placeholder file. The catch is that Git cannot re-include a file if its parent folder itself is excluded, so logs/ with a trailing slash would make the negation useless. Ignoring the folder's contents, rather than the folder, avoids the problem.

Checking why a file is ignored

When a file refuses to appear in git status, the command git check-ignore -v followed by the file's path shows which ignore file and which line is responsible. It takes the guesswork out of long ignore files assembled from several templates, and it works with global and local ignore files too.

Generated files

Build output, compiled assets and dependency folders are usually ignored and recreated during deployment. Some hosting setups, however, have no build step and serve exactly what is in the repository, in which case compiled files must be committed. Decide based on how the project is deployed, and document the decision in the README.

Large files

Uploaded media, database dumps and video files bloat a repository permanently, because every version stays in the history. Ignore folders such as uploads, keep media in proper storage and, where large binary files genuinely belong with the code, use Git LFS.

Folders with their own rules

Large repositories can place additional .gitignore files in subfolders, with patterns that apply only within that folder. This keeps rules close to the code they concern, for example a frontend folder ignoring its own build output, and stops the root file from growing into hundreds of lines.

Common mistakes

  • Deleting a committed secret without rotating it.
  • Ignoring a folder and then trying to re-include a file inside it.
  • Adding personal editor files to a shared project's ignore file.
  • Committing uploads and database dumps.

Related tools

To create new secrets after a leak, use Password Generator. To remove repeated lines from a combined ignore file, try Remove Duplicate Lines, and to compare two versions of a file, Text Diff Checker.

Secret scanning

Hosting services can scan pushes for known kinds of keys and tokens. GitHub's push protection, for example, can block a push containing a recognised secret before it becomes public. Pre-commit tools that scan staged changes add a second layer on your own computer. These checks complement a good .gitignore rather than replacing it.

Frameworks change their output folders

Build tools and frameworks change over time, adding cache folders or renaming output directories. After upgrading a framework, look at git status for unfamiliar new folders and add them to .gitignore if they are generated. Regenerating the ignore file with current templates occasionally keeps it up to date.

Reviewing before each commit

Running git status and reading git diff --staged before committing catches files that should not be there, such as local databases, exports and editor settings. Adding files by name, rather than adding everything at once in a new project, gives one more chance to notice a file that belongs in .gitignore.

Privacy

The file is assembled in your browser from built-in templates. Nothing is uploaded or stored.

Frequently asked questions

What is a .gitignore file?

A plain text file in your repository that lists patterns of files and folders Git should not track, such as dependencies, build output and logs. Each line is one pattern, and lines starting with # are comments.

Where do I put the .gitignore file?

Usually in the root folder of the repository, next to the .git folder. Its rules apply to that folder and everything below it. You can also add more .gitignore files in subfolders for rules that only apply there.

Why is a file still tracked after I ignored it?

Ignore rules only affect untracked files. If Git already tracks a file, remove it from the index with git rm --cached followed by the file name, commit that change, and from then on the rule keeps it out.

What do the patterns mean?

A trailing slash matches folders only, an asterisk matches any characters except a slash, two asterisks match across folders, and a leading exclamation mark re-includes a file that an earlier rule excluded.

Should I commit the .gitignore file?

Yes. Committing it shares the same rules with everyone who works on the project, so nobody accidentally adds build files or secrets. Personal rules for your own editor can go in .git/info/exclude instead.

Should I ignore lock files like package-lock.json?

No. For applications, commit lock files such as package-lock.json, yarn.lock, poetry.lock or Cargo.lock, because they make installs reproducible for everyone. That is why none of the templates here ignore them.

Why does the download say gitignore.txt?

Browsers do not save files whose names start with a dot, so the file is downloaded as gitignore.txt. Rename it to .gitignore, or paste the copied text into a new file with that name in your editor.