What is a .gitignore file?

A .gitignore file tells Git which files to leave out of version control: dependencies you can install again (like node_modules), build output, logs, caches, editor settings, and files your operating system leaves behind, like .DS_Store on macOS or Thumbs.db on Windows. Put it in the root folder of your repository. Its patterns apply to that folder and every folder below it.

Where the templates come from

The templates are GitHub's official collection, the github/gitignore repository, the same ones GitHub offers when you create a repository. The tool loads a copy that's refreshed every day. They come in three groups:

  • Main templates for languages, frameworks and tools, such as Node, Python, Java, Go, Rust, Unity and WordPress.
  • Global templates for editors, operating systems and other tools, such as macOS, Windows, Linux, VisualStudioCode, JetBrains and Vim. They suit a project's .gitignore as well as the global one Git can apply to all of your repositories.
  • Community templates for more specialized frameworks and tools, kept by the community, such as JavaScript/Vue or Python/JupyterNotebooks.

How to use it

  1. Start from a quick pick for a popular project type. It picks the stack's templates plus macOS, Windows and the editor usually used with it.
  2. Or search the Templates field and pick every language, framework, editor and operating system your project uses. Untick a template, or press Backspace in the field, to remove it again.
  3. The .gitignore is built as you pick, with each template under its own heading comment, in the order you picked them.
  4. Copy it, or download it and save it in the root folder of your repository as .gitignore. Browsers don't save files whose name starts with a dot, so the download arrives as gitignore.txt or gitignore: rename it to .gitignore.

Tips

  • Two templates can share a pattern, like node_modules/ in Node and Nextjs. A repeated pattern does no harm.
  • A pattern doesn't untrack a file Git already tracks. To stop tracking it but keep it on disk, run git rm --cached followed by the file's path, then commit.
  • A line that starts with ! brings back files that an earlier pattern ignored. The VisualStudioCode template uses it to keep shared settings, like .vscode/settings.json, in the repository.

Features

  • GitHub's official .gitignore templates, refreshed daily
  • Languages, frameworks, editors and operating systems in one searchable list
  • Quick picks for popular project types
  • Each template under its own heading
  • Copy or download the file