A git repository is a directory under git version control. It contains your project's files (the working tree) together with a hidden .git/ directory holding the entire commit history, branches, and configuration. Every clone of a git repository is a full copy, including all history—this is what "distributed" means in distributed version control.
Creating a repository:
git init # new repo in current dir
git init --bare # bare repo for hosting
git clone https://github.com/... # copy an existing repo
git clone --depth 1 url # shallow clone (history truncated)
Inside .git/ you find HEAD (current branch), refs/ (branches and tags), objects/ (the content-addressable object store), config (local config), and index (the staging area). The object store holds commits, trees, blobs, and tags identified by SHA-1 hashes of their contents—git is fundamentally a filesystem addressed by cryptographic hash.
A bare repository has no working tree and is used for hosting: you push to it, others pull from it, but no one edits files in it. GitHub, GitLab, and the like store bare repositories on their servers. Understanding that .git/ contains all the history—and that deleting it loses everything not pushed—is essential git literacy.
Related terms: Git, Git Commit, Git Branch, clone
Discussed in:
- Chapter 16: Version Control with Git — How Git Thinks
Also defined in: Textbook of Linux