Cleaning Branches
Cleaning Branches
Select branches through explicit prefix, merge-state, and optional age filters before permanent Git deletion.
custy cleanup branchesCategory
Quick Command
custy --dry-run cleanup brancheses [OPTIONS]Goal
Use branch cleanup for deliberate repository maintenance after merged or stale
work is no longer needed. The active CLI subcommand is plural:
custy cleanup branches.
How a Branch Becomes Eligible
All Applicable Filters Must Pass
Protected Name
Configured Prefix
Merge State
Optional Time Filter
Recommended Cleanup Journey
Review Before Deletion
git fetch --all --prune
git branch --all
custy --dry-run cleanup brancheses --prefix feature/ --merge-status merged --max-age 30dOn PowerShell, place the command on one line or use PowerShell's continuation syntax instead of the Bash backslashes shown above.
Before Normal Execution
Before You Begin
- Candidates are listedRequired
Every branch selected by dry-run is expected and recoverable if needed.
- Protected work is pushedRequired
Important commits exist in a safe branch, tag, or reviewed remote location.
- Merge status is appropriateRequired
Avoid unmerged or all unless their deletion is explicitly intended.
- Only one time filter resolvesRequired
max_age and before are mutually exclusive.
- Remote deletion is acceptableRequired
Confirm matching origin branches may be removed as well as local branches.
custy cleanup branches --prefix feature/ --merge-status merged --max-age 30d
git branch --allIf the Wrong Branch Was Deleted
Stop additional cleanup. If you know the branch's last commit SHA and the object is still available locally, recreate a local branch with standard Git recovery tools, review it, and push only if the remote branch also needs to be restored. If the commit is not known, inspect reflog and repository-host history before taking further action.
This recovery is intentionally manual because Custy does not maintain a branch deletion undo journal.