Pcornel
Automation · Git

Git Fundamentals

Cheat sheet · https://pcornel.dk/topic.php?topic=5465

Back to the Topic

Answer

Git Fundamentals explains the core Git state model: objects, commits, refs, HEAD, index, working tree and remotes, and how changes move between those boundaries.

Remember

  • File modified ≠ file staged; the index can contain a different version from both worktree and HEAD.
  • Commit recorded ≠ branch published; local refs can advance without any remote update.
  • HEAD name ≠ immutable identity; branch names move while commit IDs identify snapshots.
  • Repository object integrity ≠ project correctness; valid Git objects can contain broken automation or code.

First checks

  • git --version — version
  • git config --list --show-origin — config
  • git status — state

Verify in this order

working tree → index → commit → remote

Where it usually breaks

Git can prove which bytes and ancestry a commit represents, but cannot prove those bytes are operationally correct or deployed.

Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.

Git Fundamentals Git boundary map

BoundaryHealthy evidenceSuspicious evidence
Local stateRepository, HEAD, worktree/index and commit IDs are explicitWrong repo/ref, hidden staged/untracked state or mutable-name ambiguity
History / refsAncestry and branch/tag movement match intentUnexpected rewrite, stale tracking ref or unclear merge base
Remote syncURL/refspec, auth and remote read-back match expected commitsLocal assumptions, rejection, stale fetch or unsafe force update
Downstream proofBuild/reconciliation/target is verified independentlyPush/tag/merge success treated as deployment success

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5465

Confirmation

Confirm action

Continue?