Switch to main, pull latest, and prune local branches whose remote counterparts no longer exist
Clean up local branches after squash merges by removing branches that no longer have a remote counterpart.
git checkout main
git fetch origin main --tags
git pull origin main
Remove stale remote-tracking branches that no longer exist on origin:
git fetch origin --prune
git branch # local branches
git branch -r # remote branches
For each local branch (excluding main):
origin/<branch> remote-tracking branch exists.git diff --name-status origin/main..<branch>git branch -D <branch> (force delete is required because squash merges break git's ancestry-based "fully merged" detection).Print a summary of:
main.git push or delete remote branches — that is a user operation.origin/main, do NOT delete it. Warn the user that this branch has unmerged changes.