Skip to content

utils / command

Clean up merged branches

Deletes branches already merged into production or develop, locally or with --origin, then fast-forwards the rest

❯ /utils:cleanup-branches

Find and delete branches that hold nothing but already-merged code, then report what was removed and what is left.

Parameters

With no flag it cleans local branches only, then pulls the branches that are left.

Parameter What it does
--local Local branches only. The default, made explicit.
--origin Local branches and their counterparts on origin. It always asks before deleting a remote branch.
--no-sync Skip pulling the branches that are left. Combines with either scope.
/utils:cleanup-branches                     # local branches, then pull the rest
/utils:cleanup-branches --local             # the same, explicit
/utils:cleanup-branches --origin            # local and remote branches
/utils:cleanup-branches --no-sync           # local, no pull afterwards
/utils:cleanup-branches --local --no-sync   # the same, explicit
/utils:cleanup-branches --origin --no-sync  # local and remote, no pull

View source on GitHub