Use it when configuring, checking or troubleshooting Branch in Git.
Branch
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.
1. Branches isolate work.
2. Short-lived feature branches.
3. Protect main.
4. Delete merged branches.
5. Naming conventions.
main → feature branch → PR → main
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
HEAD selection → local branch ref → commit graph → upstream config → remote-tracking ref → fetched remote ref
Healthy evidence: HEAD is on the intended branch, worktree state is deliberate, upstream is explicit and divergence is measured against freshly fetched remote refs.
Step 2 Failure modes and next checks Narrow the fault
Suspicious evidence: committing on wrong branch, stale remote-tracking refs, hidden carried changes, accidental detached HEAD or treating branch names as immutable.
Step 3 Common mistakes Narrow the fault
- Long-lived branches drifting from main.
Step 4 Where it fails Narrow the fault
Where Branch usually goes wrong: ref identity, fast-forward/divergence, merge/rebase policy and remote tracking.
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.
- 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.
git branch -a— branchesgit switch -c feature/<name>— create branchgit branch --merged main— merged branches
ReferenceWhat it is1 section · depth on demand
Core model
Treat branch name, pointed-to commit, upstream relationship, remote-tracking ref and worktree attachment as distinct state. Branch creation, switching and publication are separate operations.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
A branch pointing at a commit shows only the current local ref position, but it does not show the upstream exists, is current or contains the same history.
Remote synchronization is covered by Remote/Pull/Push; release identity is covered by Tag.
In depth
A Git branch is a lightweight pointer to a commit that moves forward as you commit. Branches let work happen in isolation — a feature, a fix, an experiment — before merging into the main line.
git switch -c feature/ntp-oslo
git branch -a
git push -u origin feature/ntp-oslo
git branch -d feature/ntp-oslo # after merge
| Branch model | Description |
|---|---|
| Trunk-based | Short-lived branches merged into main quickly |
| GitHub flow | Branch → PR → merge to main → deploy |
| Release branches | Maintain older versions |
Short-lived branches cause fewer merge conflicts and keep automation code closer to what is deployed.
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 > Branch. 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
Branch Git boundary map
Fast local-state, history/ref, remote and downstream proof boundaries for Branch.
| 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
For Branch, rely on structured fields and stable IDs (ref identity, fast-forward/divergence, merge/rebase policy and remote tracking) rather than text formatted for display.