gitprune
Deletes local git branches that no longer exist on the remote, then runs garbage collection and prunes stale remote-tracking refs.
Usage
gitprune # safe delete
gitprune --force # force delete unmerged branches too
Flags
| Flag | Behavior |
|---|---|
| (none) | Uses git branch -d — refuses to delete unmerged branches |
--force | Uses git branch -D — deletes unmerged branches regardless |
What it does
- Lists remote branches
- Compares against local tracking branches
- Deletes any local branch with no matching remote
- Runs
git gc --prune=nowandgit fetch -pto clean up stale refs - Runs
git gcagain for a final compaction
Output from gc and fetch is collapsed into a single overwriting status line so it doesn’t flood your terminal.
Notes
- Safe to run frequently — without
--forceit will never delete a branch with unmerged commits gitrefreshcallsgitprune --forceautomatically at the end of its flow