Introduction to Git ignore and .gitignore
Learn how Git ignore rules prevent selected untracked files from being added to repository history.
Understand why generated files, local settings, and secrets are usually excluded.
Core concepts and architecture
Study .gitignore patterns, wildcards, directory rules, negation, and precedence.
Understand the difference between ignored untracked files and files already tracked by Git.
Practical implementation
Create .gitignore rules for build output, dependencies, local configuration, and temporary files.
Use git rm --cached when a previously tracked file should no longer be tracked.
Challenges and trade-offs
Ignoring a file does not remove it from existing repository history.
Incorrect ignore patterns can exclude files required for development or deployment.
Interview preparation
Explain how .gitignore works.
Why does adding a tracked file to .gitignore not automatically stop Git from tracking it?
Key takeaways
- Understand the purpose and main concepts of Git ignore and .gitignore.
- Understand how Git ignore and .gitignore works and how its components interact.
- Be prepared to explain practical implementation and real-world use cases.
- Understand common challenges, limitations, and design trade-offs.
- Practise explaining Git ignore and .gitignore clearly in a technical interview.