Git & GitHub Interview Question #19
What is .gitignore?
Git Fundamentals, Repository, Working Tree, Staging, Commits & Branch Basics Junior Beginner
Quick Interview Answer
A .gitignore file defines patterns for intentionally untracked files and directories that Git should generally ignore. Typical examples include build outputs, dependency caches, IDE-specific files, logs, and local configuration that should not enter version control.
Detailed Explanation
A .gitignore file defines patterns for intentionally untracked files and directories that Git should generally ignore. Typical examples include build outputs, dependency caches, IDE-specific files, logs, and local configuration that should not enter version control.
.gitignore does not automatically stop tracking a file that has already been committed. Already tracked files must be removed from the index separately if they should become ignored.
Code Example
# .gitignore example
bin/
obj/
.vs/
*.user
*.log
# Keep secrets out of source control.