Clean up local branches that no longer exist on remote
Deletes local branches that no longer exist on remote and reports the cleanup results.
/plugin marketplace add leobrival/topographic-plugins-official/plugin install dev@topographic-plugins-officialgit branch --show-currentgit branchgit branch -vvFetch and prune remote
git fetch --prune
Find gone branches List branches where upstream is gone:
git for-each-ref --format '%(refname:short) %(upstream:track)' refs/heads | grep '\[gone\]'
Delete gone branches
For each branch marked as [gone]:
git branch -d <branch-name>
Use -D (force) only if -d fails and after confirming with user.
Report results
Cleaned up branches:
- feature/old-feature (deleted)
- fix/resolved-bug (deleted)
Remaining branches:
- main
- develop
- feature/current-work
# Clean up stale branches
/clean-gone
# After PR merges
/clean-gone