Use git-trim to remove branches
mainThe git trim command allows you to clean up your Git repository by removing various types of branches. You can combine multiple options to perform complex cleanups.
Branch Removal Options
--prunedor-p: Removes local branches where the remote branch no longer exists.--mergedor-m: Removes local branches already merged into the current branch.--staleor-s: Removes local branches without commits in the last 3 months.--squashedor-q: Removes local branches already squash-merged into the current branch.--untrackedor-u: Removes local branches not tracking a remote branch.--reset[=remote]: Removes all local branches except those existing on the specified remote (defaults toorigin). Requires confirmation.--all: Removes all local branches except the current branch. Requires confirmation.
Modifier Options
--trackedor-t: When used with a removal option, also removes the remote tracking branch.--remoteor-r: Operates on remote branches instead of local branches.--dry-run: Lists the branches that would be deleted without actually removing them.
git trim --merged --stale
git trim --stale --remote
git trim --merged --tracked
git trim --dry-run