git-clean-gone-0.1.0 is not a library.
git-clean-gone
Run git clean-gone to delete any GitHub branches that've been deleted on the remote (e.g., after merging PRs)
Description
A Rust CLI tool to clean up local Git branches that have been deleted on the remote.
Features
- Fetches and prunes remote branches
- Identifies local branches whose remote counterparts have been deleted
- Safely deletes those branches (excludes the current branch)
- Supports dry-run mode to preview what would be deleted
- Verbose mode for debugging
Installation
# Or, from source:
Usage
Basic usage (will delete branches):
Dry run (preview without deleting):
Verbose output:
Combined:
How It Works
- Runs
git fetch -apto fetch all remotes and prune deleted remote branches - Runs
git branch -vvto list local branches with their tracking information - Parses the output to find branches marked as
: gone](remote deleted) - Filters out the current branch (marked with
*) - Deletes the gone branches using
git branch -D - Displays all remaining branches
Testing
Run the unit tests:
Alternatives
Add the following fish function to your ~/.config/fish/my_alias.fish:
function git_clean_gone_branches
git fetch -ap
git branch -vv | grep ': gone]' | grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -D
echo 'Remaining branches:'
git branch -a
end
Why I prefer my awesome super-extra Rust package:
- Works on all shells (fish, bash, zsh).
- Easier install (unless you're already using cool dotfile management)