Team Git & GitHub Guide

🙈 Ignoring Files with .gitignore

A .gitignore file is a simple text file where you list files and folders that you want Git to ignore. Ignored files won’t be tracked, which keeps your repository clean and secure.

Why Do We Need to Ignore Files?

We don’t want to commit everything into our repository. Common things to ignore include:

How It Works

  1. In the root of your project, create a new file named exactly .gitignore (the dot at the beginning is important).
  2. Open the file and add the names of the files or folders you want to ignore, with each entry on a new line.

Example .gitignore File

This is a common example for a web project:

Ignore Node.js dependency folder node_modules/

Ignore environment variables file .env

Ignore build output folder dist/

Ignore OS-specific files .DS_Store Thumbs.db

Best Practice: You should create your .gitignore file at the very beginning of a new project, before you make your first commit.

## 💡 Pro-Tip: Use Online Resources

You don’t have to create these files from memory. You can use online tools to generate a comprehensive .gitignore file for your specific project.