Pcornel
Automation · Git

Branch

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

Back to the Topic

Answer

A Git branch is a movable local reference to a commit that provides a named line of development; it is not a separate copy of repository history.

Remember

  • Branch exists ≠ upstream configured; a local branch can have no tracking relationship.
  • Branch name ≠ fixed snapshot; it moves as commits are added or refs are reset.
  • Switching branch ≠ clean isolation; uncommitted changes may carry across when Git permits it.
  • Remote-tracking branch ≠ live remote ref; it reflects the last fetch state.

First checks

  • git branch -a — branches
  • git switch -c feature/<name> — create branch
  • git branch --merged main — merged branches

Verify in this order

main → feature branch → PR → main

Where it usually breaks

A branch pointing at a commit proves only the current local ref position; it does not prove the upstream exists, is current or contains the same history.

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

Branch 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=5469

Confirmation

Confirm action

Continue?