🌱 BasicsCommonly used
How to set up a .gitignore file
Tell Git which files and folders to ignore.
Create a .gitignore file
touch .gitignoreCreates a .gitignore file in the current directory.
Add patterns one per line. Use * for wildcards.
Common .gitignore patterns
# Dependencies
node_modules/
# Environment variables
.env
.env.local
# Build output
dist/
.next/
out/
# OS files
.DS_Store
Thumbs.db
# Editor
.vscode/
.idea/Common patterns for a Node.js / Next.js project.
Ignore already-tracked files
git rm --cached filename.txt
git commit -m "Stop tracking filename.txt"If a file was already committed, remove it from tracking without deleting it locally.
When to use: You added .env to .gitignore but it was already being tracked.
Check if a file is ignored
git check-ignore -v filename.txtShows which .gitignore rule is causing the file to be ignored.