cleanup-merged-branches
Deletes local and remote git branches that have been merged into main.
Installation
Suivez les instructions du dépôt pour votre agent. Consultez les fichiers et dépendances avant l’installation.
Voir la source ↗GuidesInstructions
Cleanup Merged Branches
This skill safely deletes git branches that have been merged into the main branch.
Procedure
1. Fetch and Prune Remote
git fetch --prune
2. List Merged Branches (Preview)
# Local branches merged into main (excluding main itself)
git branch --merged main | grep -v "main" | grep -v "^\*"
# Remote branches merged into main
git branch -r --merged main | grep -v "main" | grep -v "HEAD"
3. Delete Local Branches
git branch --merged main | grep -v "main" | grep -v "^\*" | xargs -r git branch -d
4. Delete Remote Branches
# For each remote branch (e.g., origin/feature-branch)
git push origin --delete <branch-name>
Safety Notes
-
Always preview before deleting (
-dis safe,-Dforce deletes) -
Never delete
main- the grep filters exclude it - Confirm with user before deleting remote branches (destructive action)
- Protected branches - some branches may be protected on GitHub
Exemples
Consultez les exemples du dépôt source.
Voir la source ↗Historique source
- Date d’indexation
- 2026-01-20
- Mise à jour de l’index
- 2026-01-28
- Branch
- main
Les dates concernent ce répertoire. Consultez le dépôt pour l’historique du code.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!