.gitignore: A file named .gitignore that tells Git which files or folders not to track, such as build output, downloaded dependencies, local settings, and secret keys.

Example

Your Node.js project has a node_modules folder with thousands of files. Adding node_modules/ to .gitignore keeps it out of your commits, so the repository stays small and clean.

What Usually Goes in .gitignore

TypeExamples
Build outputtarget/, bin/, obj/, dist/, build/
Dependenciesnode_modules/, venv/, .venv/
IDE settings.idea/, .vscode/ (some teams share these)
Secrets and local config.env, appsettings.Development.json with keys
OS files.DS_Store, Thumbs.db

GitHub offers ready-made .gitignore templates for most languages when you create a repository.

How It Works

Each line is a pattern. folder/ ignores a whole folder, *.log ignores all log files, and a line starting with ! makes an exception. .gitignore only affects files Git is not already tracking.

If You Committed Something by Mistake

  1. Add the file or folder to .gitignore.
  2. Remove it from tracking with git rm --cached, without deleting it from your disk.
  3. Commit the change.

If you committed a password or API key, removing it later is not enough; it stays in history. Tell your mentor and change (rotate) the key immediately.

Related terms

  • Git: the tool that reads .gitignore.
  • Commit: .gitignore keeps unwanted files out of commits.
  • Repository: where the .gitignore file lives.
  • README: another standard file at the top of a repository.

Related guides

Frequently asked questions

What is .gitignore used for?

It tells Git which files and folders not to track, such as build output, dependencies, local settings, and secrets.

Why is my .gitignore not working?

Usually because the file was already tracked. Remove it from tracking with git rm --cached and commit.

Should .env files be in .gitignore?

Yes. They often contain passwords and keys, which should never be committed.

Where should the .gitignore file be?

Usually in the root folder of the repository, though sub-folders can have their own.

Explore more internship terms

The IT Internship Glossary explains 199 terms you will hear before and during your internship, with simple definitions and real examples.

Browse all 199 terms
Dhaivat Ajwaliya

About the author

Dhaivat Ajwaliya

Dhaivat has 16+ years of experience in the IT industry, working on AI and cloud technologies, project delivery, and engineering leadership. He has interviewed and mentored many interns, wrote The Lost Intern, and runs the non-commercial Career Impact Initiative, mentoring students for free.