Gitignore Generator
Tick the technologies in your project. The patterns are combined into one file with a heading for each part, and you can add lines of your own.
Save the result as .gitignore in the top folder of your repository. Files that are already tracked stay tracked until you remove them with git rm --cached.
Worked examples
Two templates
Node.js and macOS
# Node.js node_modules/ npm-debug.log* yarn-debug.log* yarn-error.log* pnpm-debug.log* ...
Each template has a heading and the first lines are shown here.
About Gitignore Generator
A .gitignore file tells Git which files to leave out of a repository: dependencies you can download again, build output, caches, editor settings and, above all, files that hold secrets. Starting from a good list saves you from committing thousands of generated files, or an environment file with a password in it, on your first day.
Tick the languages and tools you use, plus the operating systems and editors your team works on, and the patterns are merged into one file in a sensible order. Each group has its own comment heading so you can see why a line is there, and your own extra lines are added at the end under a project heading. There are more than twenty templates, from Node.js, Python, Java, Go and Rust to Terraform, Unity, Android and the common editors. The patterns were written for this tool and cover the usual output folders and caches of each ecosystem.
How to use Gitignore Generator
- Tick the templates that match your project, your editors and your operating systems.
- Add any extra lines of your own, one per line.
- Read the combined file in the result box.
- Copy it and save it as .gitignore at the top of your repository.
Common uses
- Starting a new repository
- Adding the right patterns when you add a language to a project
- Keeping editor and system files out of shared repositories
- Making sure environment files and keys are never committed
Frequently asked questions
Why is my file still tracked after I added it?
Git only ignores files that are not already tracked. Remove it from the index with git rm --cached name, commit, and the ignore rule will then apply.
What does a trailing slash mean?
A pattern ending in / matches folders only, so build/ ignores a folder called build but not a file with that name.
How do I keep one file that a pattern would hide?
Add a line starting with ! after the pattern, for example !.vscode/settings.json. It cannot bring back a file whose parent folder is ignored.
Should I ignore lock files?
Usually no. Lock files such as package-lock.json record exact versions and should be committed for applications. None of the templates ignore them.
What about secrets I already committed?
Ignoring a file does not remove it from history. If a secret was committed, treat it as exposed, change it, and then clean the history if needed.