A .gitignore generator builds the file that tells Git which files to leave out of your repository. Tick the languages, frameworks, operating systems and editors your project uses, add any lines of your own, and this .gitignore generator combines GitHub's ready-made templates into one clean file, with a heading for each part and no repeated lines. Copy it or download it, and save it as .gitignore in the top folder of your project.
How to use the .gitignore generator
- Tick your languages and frameworks, such as Node.js, Python or Laravel.
- Tick your operating systems, so files like .DS_Store and Thumbs.db stay out.
- Tick your editors, such as Visual Studio Code or JetBrains IDEs.
- Add your own lines, such as .env or a build folder.
- Copy or download the file and save it as .gitignore in the root of your repository.
The file updates as you tick each box, and a line shows how many patterns it holds.
What a .gitignore file does
Every project creates files that shouldn't be shared: installed packages, build output, logs, editor settings and secrets such as .env files. A .gitignore file lists patterns for those files, and Git leaves anything that matches out of git status and git add. Untracked files that match are ignored; files Git already tracks aren't affected, so add the .gitignore early, before the first commit.
Where the templates come from
The patterns come from GitHub's own collection of .gitignore templates, the same list GitHub uses for the template chooser when you create a new repository. The collection is released under the CC0 public domain dedication. GitHub keeps templates for languages and technologies in its main folder, and templates for editors, tools and operating systems in a Global folder, which it suggests merging into project templates or adding to your global settings. This tool includes both kinds, with their comments removed so the file stays short.
Pattern rules in brief
The Git documentation explains how each line is read:
- Blank lines match nothing and can be used as separators. Lines starting with # are comments.
- A trailing slash, as in build/, matches only directories.
- A slash at the start or in the middle makes the pattern relative to the .gitignore's own folder; otherwise it can match at any level below.
- * matches anything except a slash, ? matches any one character except a slash, and ranges such as [a-z] match one character from the range.
- A leading **/ matches in all directories, so **/foo matches foo anywhere.
- A leading ! re-includes a file excluded by an earlier pattern, but a file can't be re-included if its parent directory is excluded.
Example
For a Laravel project developed on a Mac in Visual Studio Code, tick Laravel, macOS and Visual Studio Code, then add coverage/ in your own lines. The file starts with a # Laravel heading and patterns such as /vendor/ and .env, continues with the macOS patterns such as .DS_Store, then the editor patterns, and ends with a # Project files heading and your own line. Any pattern that two templates share appears only the first time.
Global or per project?
Operating-system and editor files are created by your own setup, not by the project. Many developers put those patterns in a global ignore file instead, set with git config --global core.excludesFile, so every repository on their computer ignores them. Adding them to the project's .gitignore works too and protects the repository when teammates use other systems. Choose whichever fits your team.
Fixing files that are already tracked
If a file was committed before you ignored it, Git keeps tracking it. Remove it from the index without deleting it from disk with git rm --cached followed by the file name, then commit. From then on, the pattern in .gitignore keeps it out.
Saving the file
The download is named .gitignore. Some systems hide files whose names start with a dot, and some browsers rename them, so if you see gitignore or gitignore.txt instead, rename it to .gitignore. Copying the text into a new file in your editor works just as well.
Your privacy
The file is put together in your browser from templates built into this page. Nothing you type, including your own patterns, is uploaded.
What the common templates ignore
- Node.js: node_modules, logs, coverage reports and environment files such as .env.
- Python: __pycache__ folders, compiled files, virtual environments and build folders.
- Java: compiled .class files, packaged .jar and .war files and log files.
- Laravel: the vendor and node_modules folders, .env files and the public build folder.
- macOS: .DS_Store files and other folder metadata.
- Windows: Thumbs.db and other thumbnail cache files.
- Visual Studio Code: the .vscode folder, keeping shared settings files you may want to commit.
Read through the generated file before you commit it. Templates are a starting point, and every project has its own folders worth adding or removing.
Common mistakes
- Adding .gitignore after committing secrets. Ignoring a file doesn't remove it from history.
- Ignoring the lock file by habit. Lock files such as package-lock.json usually belong in the repository.
- Saving it in a subfolder when you meant the whole project.
- Using backslashes as folder separators; Git uses /.
What next
Use this often? Add .gitignore to your Home screen.
Frequently asked questions
What does the .gitignore generator do?
It combines GitHub's .gitignore templates for the languages, operating systems and editors you tick, plus your own lines, into one file without repeated patterns.
Where do the .gitignore templates come from?
From GitHub's github/gitignore collection, the list GitHub uses when you create a repository. It's released under CC0.
Where should I save the .gitignore file?
In the top folder of your Git repository, named exactly .gitignore, ideally before your first commit.
Why is a file still tracked after I ignored it?
Git keeps tracking files that were committed before. Run git rm --cached with the file name and commit to stop tracking it.
Is anything I type uploaded?
No. The file is built in your browser from templates included in the page.
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.