Search

PythonReactSEOPDF
GitHub Skill

cleanup-merged-branches

Deletes local and remote git branches that have been merged into main.

Tai-ch0802☆ 7 Repository stars2 Repository forks

Installation

Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.

View source ↗Guides

Skill instructions

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 (-d is safe, -D force 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

Examples

Read the usage examples in the source repository.

View source ↗

Source history

Indexed on
2026-01-20
Index updated
2026-01-28
Branch
main

Index and sync dates describe this directory. View the source repository for code history.

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!