You inherit a repo with 400 stale branches and no conventions. How do you clean it up safely?
AdvancedProductionBranching and workflow design
Answer
List merged and stale branches, publish the deletion list with a deadline, then delete in batches while keeping tags. Turn on auto-delete head branches, add a branch-name ruleset and a scheduled workflow that reports branches with no commits for 90 days.
git for-each-ref --sort=committerdate refs/remotes/origin \
--format='%(committerdate:short) %(refname:short)' | head -50
git branch -r --merged origin/main | grep -v 'main$'
More on Branching and workflow design
How would you choose a branching strategy for a team of 40 engineers shipping a SaaS product several times a day?IntermediateWhen is GitFlow still the right choice in 2026?IntermediateHow do you support multiple released versions (1.x, 2.x, 3.x) without chaos?AdvancedHow do feature flags change your merge and release process?IntermediateWhat branch naming and commit conventions do you enforce and how?BeginnerSquash, merge commit or rebase: what do you set as the allowed method on production repos and why?Intermediate