.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
| Type | Examples |
|---|---|
| Build output | target/, bin/, obj/, dist/, build/ |
| Dependencies | node_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
- Add the file or folder to .gitignore.
- Remove it from tracking with git rm --cached, without deleting it from your disk.
- 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
- Build a GitHub Portfolio That Gets You Internship Interviews
- What to Do in Your First Week of an IT Internship
- Common IT Internship Mistakes
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