Pcornel
Automation · Git

Git Troubleshooting

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

Back to the Topic

Answer

Git Troubleshooting isolates failures across repository state, refs/history, worktree/index, remote configuration, transport/authentication, server policy and downstream automation without destroying recoverable evidence.

Remember

  • Command error ≠ repository corruption; many failures originate in state, permissions, remote policy or transport.
  • Changed symptom ≠ root cause fixed; a retry can succeed after transient conditions without explaining the boundary.
  • Reset/clean success ≠ safe recovery; destructive commands can erase the evidence or work that explained the issue.
  • Remote rejection ≠ local Git bug; authentication, authorization, protected refs and server hooks are independent boundaries.

First checks

  • git status; git log --oneline -5 — state
  • git reflog — recover lost commits
  • GIT_TRACE=1 git <cmd> — debug

Commands

git status --short --branch
Read-only/validation observation for current branch, working-tree changes and divergence indicators.

Verify in this order

symptom → git state → reflog/trace → fix

Where it usually breaks

A Git command succeeding after a change proves only that operation now passed. Root cause closes when the first failed boundary is explained and local/remote state plus downstream effects are verified.

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

Git Troubleshooting 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=5480

Confirmation

Confirm action

Continue?