💫 cleanup is a CLI tool for keeping your Git repositories clean. It removes old branches in one or more repositories with a single command.
Project status: In active development. Can be used without warranty.
You merely need to provide the path to your repository. For example, change into your project directory and remove all gone branches like this:
$ cleanup branches .If you want to get a preview of branches that will be deleted, just perform a dry run.
$ cleanup branches --dry-run .There appear some branches that probably shouldn't be deleted? You can simply exclude them:
$ cleanup branches --exclude="feature/3, feature/4" .Cleaning multiple repositories at once
Many developers work on multiple projects at once. Let's assume that these projects have a common parent directory.
Deleting gone branches in all of these repositories is fairly simple:
$ cleanup branches --has-multiple-repos projectsTo find out which branches are gone on the remote, cleanup uses the output of git branch -vv.
$ git branch -vv
* master 34a234a [origin/master] Merged some features
feature/1 34a234a [origin/feature/1: gone] Implemented endpoints
feature/2 3fc2e37 [origin/feature/2: gone] Added CLI flagsBased on that output, cleanup performs git branch -d <branch> on all gone branches. Maybe you've been doing the same thing manually for each branch in each repository.
Download the latest release of cleanup.
Linux/macOS
Copy the downloaded binary into a directory like /usr/local/bin. Make sure the directory is listed in PATH.
Windows
Create a directory like C:\Program Files\cleanup and copy the executable into it. Add the directory to Path.
Especially developers working in larger teams may want to clean up their repositories periodically.
Linux/macOS
Edit cron's job table.
$ crontab -eAdding a line like this will run cleanup every day at 11 PM for all repositories. Make sure you provide correct paths to the cleanup binary and project directory.
0 23 * * * /usr/local/bin/cleanup branches --has-multiple-repos /home/user/projectsWindows
Just create a scheduled task like this – and make sure to provide correct paths for the cleanup executable and project directory.
> SCHTASKS /CREATE /SC DAILY /ST 23:00 /TN "Clean up repositories" ^
/TR "C:\Path\To\cleanup.exe branches --has-multiple-repos C:\Path\To\Projects"
クリーン