-
Notifications
You must be signed in to change notification settings - Fork 0
gitprune
Brandon Shoop edited this page Jun 2, 2026
·
1 revision
Deletes local git branches that no longer exist on the remote, then runs garbage collection and prunes remote-tracking refs.
gitprune # safe delete
gitprune --force # force delete unmerged branches too| Flag | Behavior |
|---|---|
| (none) | Uses git branch -d — refuses to delete unmerged branches |
--force |
Uses git branch -D — deletes unmerged branches |
- Lists remote branches (
git branch -r) - Compares against local tracking branches (
git branch -vv) - 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 piped through show_progress so only a single overwriting status line is shown.
- Safe to run frequently — without
--forceit will never delete a branch with unmerged commits -
gitrefreshcallsgitprune --forceautomatically at the end of its flow