Skip to main content

Overview

Branch Cleanup

Advanced

Safely remove obsolete Git branches using configurable filters while protecting important branches.

Commandcusty cleanup branches

Category

Maintenance

Quick Command

custy cleanup branches

gitbranchescleanupmaintenance

Overview

Branch Cleanup removes Git branches that satisfy the cleanup rules configured for your project.

Unlike Backup Cleanup, this command operates directly on your Git repository.

To minimize the risk of accidental branch deletion, Custy applies multiple safety checks before removing any branches.

Only branches matching the configured cleanup filters are considered.



What Branch Cleanup Does

Responsibilities

Scan Local Branches

Inspect local Git branches before determining which branches are eligible for cleanup.

Apply Cleanup Filters

Evaluate branch prefixes, merge status, branch age, and other configured filters.

Protect Important Branches

Prevent removal of protected branches regardless of configured filters.

Remove Eligible Branches

Delete only branches that satisfy every configured cleanup rule.

Branch Cleanup

Branch cleanup process
Example output after Custy removes merged release branches according to the configured cleanup rules.

Safety First

Branch Cleanup is intentionally conservative.

By default:

  • no branch prefixes are configured,
  • no branches are selected,
  • no branches are deleted.

Projects must explicitly configure which branch prefixes may be cleaned.

This prevents accidental deletion immediately after installing Custy.



Workflow Integration

Branch Cleanup is available as the standalone public command:

custy cleanup branches

The internal cleanup_branches profile is intentionally not included in Custy's public automated release workflows and is not accepted as a public Run argument.

This ensures that branch removal always remains an explicit user decision.