A .gitignore file lists files and folders Git should never track: dependencies, build output, logs and secrets.
node_modules/, vendor/: installed packages
.env: secrets and passwords
*.log: any file ending in .log
/build: only the build folder in the root
!keep.log: an exception
If a file was already committed, ignoring it is not enough. Remove it from tracking with git rm --cached file.
💡 Key Takeaways: Git .gitignore
Mastering Git .gitignore helps you write clean and reliable Git code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.