profile

Néstor's Blog

Clean Up Merged Git Branches

git cli maintenance
git remote prune origin

See What Will Be Removed

Preview before removing:

git remote prune origin --dry-run

Delete Local Branches Too

If you also want to delete the local copies:

# Delete all branches merged into main
git branch --merged main | grep -v "main" | xargs git branch -d