This simple Windows batch script helps you safely clean up local Git branches that:
- Have already been deleted from the remote (e.g., GitHub)
- And have already been merged into your current branch (typically
mainordevelop)
It only deletes safe branches — those merged and removed remotely.
- Detects local branches that are:
- Gone from the remote (
origin) - Already merged into your current branch
- Gone from the remote (
- Shows a preview before deleting:
- Lists which branches will be deleted
- Lists which branches will be kept
- Works on:
- Windows CMD (double-clickable)
- Download or clone this repository.
- Drop the
clean-local-branches.batfile into any local Git repo folder. - Double-click the
.batfile to run it. - Review the branches marked for deletion and confirm when prompted.