Use it when configuring, checking or troubleshooting Repository in Git.
Repository
A Git repository is a project's complete version history: all commits, branches and tags, stored in the .git directory alongside a working tree of checked-out files. Clones are full copies of the repository.
1. A repository holds code and history.
2. Structure clearly.
3. CODEOWNERS for reviews.
4. Branch protection.
5. Avoid large binaries (use LFS).
repo → files + history
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
filesystem path → repository root/Git dir → objects/index → HEAD/local refs → remotes/worktrees → consumer
Healthy evidence: repository root and metadata location are explicit, refs resolve, worktree/index state is known and consumers use the intended repository/ref.
Step 2 Verification path Verify boundary
Record repository URL/path, commit SHA, ref, remote and working-tree/index state; inspect the runtime/control-plane result; then query the repository graph/refs and checked-out or consumed revision through an independent read path and compare it with the versioned intent. For Git → Repository, the evidence must connect the control-plane result to the repository graph/refs and checked-out or consumed revision and explain any gap between desired, controller-reported and consumer-visible state.
Step 3 Failure modes and next checks Narrow the fault
Suspicious evidence: wrong repository root, nested repo confusion, corrupt refs, unexpected worktree association or cleanup performed before preserving evidence.
Step 4 Common mistakes Narrow the fault
- Several unrelated projects in one repository without structure.
Step 5 Where it fails Narrow the fault
Failure analysis for Git → Repository should follow the path through the components: working tree/index → commit graph → ref update → transport/remote → remote refs → consumer checkout/read-back. Common failure classes include wrong repository/ref, force-update surprises, detached HEAD, uncommitted changes, stale remote refs, credential/transport failure and consuming a branch name without recording SHA. Before retrying a mutating operation, read current target state using the stable identity repository URL/path, commit SHA, ref, remote and working-tree/index state; if state is unknown, stop broad retries.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Repository exists ≠ worktree clean; tracked, staged and untracked changes can still be present.
- Directory contains .git ≠ normal standalone repository; .git may be a file pointing to shared metadata or worktree state.
- Object database present ≠ refs healthy; refs can be missing, stale or inconsistent independently.
- Repository reachable ≠ repository trusted; provenance and access policy remain separate security boundaries.
git rev-parse --show-toplevel— repo rootgit count-objects -vH— size- README, CODEOWNERS, .gitignore present — hygiene
ReferenceWhat it is1 section · depth on demand
Core model
Treat repository identity, root, object database, configured refs and worktree association as separate facts. A repository may be bare, non-bare, nested or linked through worktrees, so path alone is not sufficient identity.
ReferenceWhy it matters1 section · depth on demand
In depth
A Git repository is the .git directory containing all objects (commits, trees, files) and references (branches, tags), plus the working tree checked out from it. A clone is a full copy, so anyone can work offline and history is not tied to one server.
git init network-config
git remote add origin git@github.com:org/network-config.git
git remote -v
git log --oneline --graph --all | head
| Repository layout tip | Reason |
|---|---|
| README with purpose and usage | Onboarding |
| Separate data from code | Easier review |
.gitignore for generated files | Clean diffs |
| Branch protection on main | Enforce review and CI |
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
Opening a valid repository shows Git metadata is readable, not that its worktree is clean, its refs are intended or its content is safe to consume.
Mechanics
Git → Repository is owned at runtime by the Git client and repository object database/ref namespace used by automation and review workflows. Its durable intent is versioned commits, refs, remote configuration and repository policy; the stable identity contract is repository URL/path, commit SHA, ref, remote and working-tree/index state. The consumer-visible target is the repository graph/refs and checked-out or consumed revision. The operating invariants are that commit identity is immutable, branch/ref intent is explicit, remote tracking is understood, dirty worktree state is visible and automation records the exact SHA consumed. Follow the chain of components working tree/index → commit graph → ref update → transport/remote → remote refs → consumer checkout/read-back and record which layer currently owns truth. The linked authority for bounded mechanics is Git Documentation; documentation support is separate from observed lab/production Evidence.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Git > Repository. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://git-scm.com/docs · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Repository Git boundary map
Fast local-state, history/ref, remote and downstream proof boundaries for Repository.
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Local state | Repository, HEAD, worktree/index and commit IDs are explicit | Wrong repo/ref, hidden staged/untracked state or mutable-name ambiguity |
| History / refs | Ancestry and branch/tag movement match intent | Unexpected rewrite, stale tracking ref or unclear merge base |
| Remote sync | URL/refspec, auth and remote read-back match expected commits | Local assumptions, rejection, stale fetch or unsafe force update |
| Downstream proof | Build/reconciliation/target is verified independently | Push/tag/merge success treated as deployment success |
Deep reference
Healthy vs suspicious evidence
Output interpretation
Capture at minimum repository, ref, SHA, remote, ahead/behind or fetch/push result, worktree/index status, errors and consumer-observed SHA.