Git Prune Branches Local

Clean up local git branches that have been merged into main/master. Use when: (1) User says 'prune local branches' or 'clean local branches', (2) User wants to delete only local merged branches without touching remote.

takazudo 6eeedc7 1.1 KB Updated

File contents

Git Prune Branches (Local)

Check and prune local branches that have been merged:

  1. Get the list of all local branches using git branch
  2. For each branch, check if it has been merged into the main branch using git branch --merged
  3. Exclude protected branches (main, master, develop, etc.)
  4. Create a list of branches that are safe to delete
  5. Present the deletion list to the user clearly
  6. Ask for confirmation: "The following local branches will be deleted. Proceed? (yes/no)"
  7. If user confirms with "yes" or similar affirmative response, delete the branches using git branch -d <branch-name> for each branch
  8. Report the results

Important: Never delete:

  • The currently checked out branch
  • Protected branches: main, master, develop, development, staging, production
  • Branches that are not fully merged (unless explicitly requested)

takazudo/claude-resources/tree/main/skills/git-prune-branches-local commit 6eeedc77c1

Frequently asked questions

npx skillmds@latest add takazudo/git-prune-branches-local