What are the common files to ignore in Git?

Some files are not part of your source code, and you should not commit them. You list them in a file named .gitignore, one pattern per line. A line starting with # is a comment.

TypeExamples
Dependenciesnode_modules/, vendor/
Logs and temporary files*.log, *.tmp, *.cache
Secrets and local settings.env, *.pem, config.local.php
Build outputdist/, build/, *.class
System files.DS_Store, Thumbs.db
Editor files.idea/, .vscode/, *.swp
# dependencies
node_modules/
vendor/

# logs and secrets
*.log
.env

# system files
.DS_Store
Thumbs.db

Note that .gitignore does not work for files which are already tracked. See Git Ignore.


Learn more about the similar topics:
Tutorials
Git Init
Git Status
Git Add
Git Commit
Git Log
Git Diff
Git Ignore (.gitignore)
Exercises & Assignments
Check the status of files in a Git repository
Stage only selected files and commit them separately
Show the commit history in one line per commit
See the changes of a file before staging and before commit
Ignore all .log files with .gitignore
Unstage a file
Delete a file with git rm
Interview Questions & Answers
How can you add files to Git?
How can you commit a file in Git?
What are the common files to ignore in Git?
How to remove untracked files in Git?
What is the staging area in Git?
What is the difference between git add and git commit?
What is HEAD in Git?