A command-line tool to easily delete all git local and remote branches except 'main'. Delete Git branches in bulk ✂️
-
Delete Local Branches: Easily manage and remove unnecessary local branches in your Git repository with an interactive CLI interface.
-
Delete Remote Branches: Clean up remote branches that are no longer needed by pushing deletions directly to the origin.
-
Branch Exclusion: Exclude specific branches (e.g., main, origin/main) from being selected for deletion to avoid accidental removal of important branches.
-
Interactive Selection: Choose which branches to delete through a user-friendly prompt, with checkboxes for easy multi-selection.
-
Confirmation Step: Prevent accidental deletions by requiring confirmation before proceeding with branch removal.
$ npm i -g branchkiller
$ branchkiller
By default, branchkiller will scan your local and remote branches, excluding branches like your current local branch, main and origin/main from being selected for deletion.
ARGUMENT | DESCRIPTION |
---|---|
-e, --exclude [branches...] | Exclude branches (default: ["main","origin/main",current local branch]) |
--no-local | Do not delete local branches |
--no-remote | Do not delete remote branches |
--no-interactive | Do not ask for confirmation before deleting branches |
-V, --verbose | Be verbose when deleting branches, showing them as they are deleted |
-h, --help | Display help for command |
-v, --version | Display branchkiller version |
- Exclude local branch
branchkiller --exclude mylocalbranch
# other alternative:
branchkiller -e mylocalbranch
- Exclude remote branch
branchkiller --exclude origin/myremotebranch
# other alternative:
branchkiller -e origin/myremotebranch
- Exclude multiple branches (local and remote)
branchkiller --exclude mylocalbranch origin/myremotebranch
# other alternative:
branchkiller -e mylocalbranch origin/myremotebranch
Contributions are welcome! Please feel free to fork the repository, make changes, and submit pull requests.
MIT © Sergio Navarro