A version control system (VCS) records committed versions of tracked files so collaborators can branch, merge, compare, and restore states that exist in the repository history. It cannot recover an untracked file or an uncommitted edit that was never captured by Git, and local recovery records such as the reflog expire.

Git is a distributed VCS: a normal clone receives the objects reachable from the refs it fetches, while shallow clones intentionally omit older history and partial clones can defer selected objects until needed. Workflows such as GitFlow or trunk-based development define how teams coordinate changes; they are conventions layered on Git rather than properties of its object model.

Working Tree, Index, Repository, and Remote

Git moves snapshots through distinct states. The working tree is what tools edit. The index is the proposed next snapshot. A commit stores that snapshot and parent links in the local object database. Branches are movable refs to commits; remote-tracking refs are the last fetched view of another repository. fetch updates remote-tracking refs without integrating them; pull fetches and then merges or rebases according to configuration.

working tree --git add--> index --git commit--> local commit graph
remote-tracking refs <--git fetch-- remote refs
local refs --git push--> remote refs

Use restore for working-tree/index content and switch for branches. reset moves a ref and may also replace index or working-tree state, so check its mode before using it. For a published mistake, create a reverting commit; do not rewrite the shared ref.

Essential Git Commands

IntentCommandSafety boundary
Inspect stategit status, git diff, git log --graphRead-only; start here
Stage selected contentgit add -pChanges the index, not history
Change branchgit switch <branch>Refuses unsafe overwrites by default
Recover a filegit restore <path>Discards unstaged edits; inspect first
Integrate remote workgit fetch, then git merge or git rebaseMakes the integration choice explicit
Undo published changegit revert <commit>Adds history without changing old IDs
Inspect lost refsgit reflogLocal recovery record; expires eventually

A flat command list hides the state transition. Name the source state, destination state, and whether the operation discards data before running it.

Git vs Hosting Platforms

Git defines objects, commits, refs, remotes, and transfer protocols. GitHub, GitLab, and Azure DevOps host repositories and add identity, permissions, pull requests, protected branches, issues, automation, and marketplaces. A repository can move between hosts without changing Git’s commit graph; platform workflows, permissions, and automation do not move automatically.

Choose a host for governance, integration, compliance, and operator cost. Do not describe a GitHub pull request or Actions workflow as a Git feature, and do not treat a local Git clone as a backup of host-side issues or branch protections.

Repository Strategy

BoundaryMonorepoMultirepo
Cross-component changeOne atomic commit and reviewCoordinated versions and rollout
Dependency policyCentral graph can enforce consistencyEach repository owns its cadence
Ownership and accessPath-based controls need toolingRepository boundary is explicit
CIAffected-graph execution is required at scaleSmaller pipelines, but integration moves downstream
ReleaseShared source does not require one releaseIndependent by default

Use a monorepo when atomic cross-component changes and one dependency/build policy justify investing in an affected-build graph and path ownership. Use multiple repositories when access isolation and independent lifecycle dominate. Company logos are not evidence: measure clone/fetch size, CI fan-out, cross-repo coordination, and release coupling in the actual system.

Narrow CI Fetches Before Tuning Depth

--depth=1 limits history reachable from fetched refs; it does not stop a broad refspec from advertising or fetching every branch. First request only the ref needed by the job, suppress tags if they are unnecessary, then consider shallow history, partial clone filters, sparse checkout, and a local object cache. Measure negotiated objects and bytes before and after.

git -c remote.origin.fetch='+refs/heads/main:refs/remotes/origin/main' \
  fetch --no-tags --depth=1 origin main

Narrowing refs can break jobs that discover release branches or calculate versions from tags. Make each job declare the history and refs it needs rather than applying one aggressive checkout globally.

Semantic Versioning and the Release Contract

SemVer only works after the project defines its public API. MAJOR.MINOR.PATCH means incompatible API change, backward-compatible functionality, and backward-compatible fix. 0.y.z signals unstable public API. Prerelease identifiers sort below the corresponding normal version; build metadata does not affect precedence.

Compatibility needs evidence: API diff, consumer tests, migration checks, and a deprecation window. This repository derives minor/patch release intent from typed commit/PR policy and reserves a breaking marker on the PR title for a major. The mechanism is repository-specific, while SemVer precedence is not.

Non-normative source visual

The Alpha → Beta → RC sequence is one release convention, not a SemVer requirement. SemVer permits arbitrary dot-separated prerelease identifiers and defines how they compare; each project defines its own stages, promotion gates, and compatibility evidence.

References

1 item under this folder.