Skip to content

Instantly share code, notes, and snippets.

@chiefmikey
Last active May 21, 2022 21:49
Show Gist options
  • Save chiefmikey/994667b145e63de8ae73b2e0f8709d3a to your computer and use it in GitHub Desktop.
Save chiefmikey/994667b145e63de8ae73b2e0f8709d3a to your computer and use it in GitHub Desktop.
Git delete n oldest remote branches
# Delete 10 oldest branches
git fetch --prune && \
git branch -r --sort=committerdate | head -n 10 | sed 's/ origin\///' | xargs git push origin --delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment