Branch Health
Rule: Always run this before opening a PR or pushing. Never assume your branch is clean.
Check Sequence
Run in order — stop and fix if any step shows a problem:
Local status — uncommitted or untracked changes
git statusFetch + compare against remote — updates refs without merging
git fetch origin git status -sbCommits missing from your branch — what main has that you don't
git log HEAD..origin/main --onelineYour commits not yet in main — what you'd be pushing
git log origin/main..HEAD --onelineConflict preview — dry-run merge, always abort after
git merge --no-commit --no-ff origin/main git merge --abort
Reading Results
- Behind main → rebase before continuing:
git pull --rebase origin main - CONFLICT detected → resolve conflicts before pushing
- Ahead with no conflicts → branch is ready
Replace
mainwithmasterordevelopdepending on the project's base branch.