What is a Git repository?

Why Interviewers Ask This

Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Git & GitHub basics — a prerequisite for any developer role.

Answer

A Git repository (repo) is a directory that Git tracks. It contains all project files plus a hidden .git/ folder that stores the complete history, configuration, and metadata. The .git/ folder contains: objects/ (all file content, commits, trees — stored as SHA-1 hashed blobs), refs/ (branches, tags — pointers to commits), HEAD (pointer to the current branch or commit), config (repo-level configuration), index (the staging area). Two types: Local repository — on your machine; Remote repository — hosted on a server (GitHub, GitLab, etc.) for sharing with collaborators. Initialize a new repo: git init — creates the .git/ folder in the current directory. Clone an existing repo: git clone https://github.com/user/repo.git — creates a local copy including the full history. A bare repository (git init --bare) stores only the Git data without a working directory — used for remote/server repositories.

Common Mistake

A common mistake is memorizing definitions without understanding implications. When asked this question, go one level deeper — explain what happens when this concept is misused or ignored.