Branch
Cheat sheet · https://pcornel.dk/topic.php?topic=5469
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— branchesgit switch -c feature/<name>— create branchgit 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
| 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 |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5469