Local branches accumulate for different reasons, so one cleanup command is not safe for every situation. A branch whose upstream is gone is different from one already merged into main, and both differ from a local branch you want to discard regardless of its merge status.
This post compares all three cases with Git Bash and PowerShell commands. The key safety distinction is -d versus -D: -d protects unmerged work, while -D bypasses that check. In particular, the gone-upstream command force-deletes matches without pausing for a preview, so inspect the list first if you need to protect local-only commits.
Choose the cleanup that matches the branch state, change the integration branch names to fit your repository, and do not force-delete work you may need.
Top comments (0)