What is a Git repository?
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.
Previous
What is the difference between Git and GitHub?
Next
What are the three stages of a file in Git?