Git & GitHub Interview Question #117
What is the .git directory?
Advanced GitHub Actions, Repository Internals, Submodules, LFS & Diagnostic Tools Senior Advanced
Quick Interview Answer
The .git directory contains the local repository's metadata and object database. It includes references, configuration, logs, the index, objects, and other internal data required for Git history and operations.
Detailed Explanation
The .git directory contains the local repository's metadata and object database. It includes references, configuration, logs, the index, objects, and other internal data required for Git history and operations.
Deleting .git from a working directory removes its local Git repository metadata, although the ordinary project files remain. Developers should not manually edit internal files unless they understand Git's storage model.
Code Example
# Show repository metadata location
git rev-parse --git-dir
# Show repository root
git rev-parse --show-toplevel