Interview Prep/Git & GitHub/Branching and workflow design

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$'
All Git & GitHub questions Roadmap: Git & GitHub

More on Branching and workflow design