Files
alirezarezvani--claude-skills/.claude/commands/git/clean.md
T
wehub-resource-sync a1fa97429b
Release / Tag + GitHub Release (push) Waiting to run
Deploy Documentation to Pages / build (push) Waiting to run
Deploy Documentation to Pages / deploy (push) Blocked by required conditions
Sync Codex Skills Symlinks / sync (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 12:41:47 +08:00

1.5 KiB

description
description
Clean up merged branches locally and on remote, keeping only main, dev, and gh-pages.

Clean up stale branches that have been merged or are no longer needed.

Steps

  1. List local branches to delete (excluding main, dev, gh-pages):
git branch | grep -v -E '^\*|main$|dev$|gh-pages$'

Report what will be deleted. If no branches found, say "No local branches to clean" and skip to step 3.

  1. Delete local branches that are fully merged:
git branch -d <branch-name>

If a branch is not fully merged, report it to the user and ask whether to force-delete. Do NOT force-delete without confirmation.

  1. List remote branches to delete (excluding main, dev, gh-pages, HEAD):
git branch -r | grep -v -E 'origin/main$|origin/dev$|origin/gh-pages$|origin/HEAD'

Report what will be deleted. If no branches found, say "No remote branches to clean" and skip to step 5.

  1. Confirm with the user before deleting remote branches. Show the full list and wait for approval. Then delete:
git push origin --delete <branch-names>
  1. Prune stale remote refs:
git remote prune origin
  1. Report final state:
git branch        # local
git branch -r     # remote

Present a summary:

Item Count
Local branches deleted N
Remote branches deleted N
Remaining local main, dev
Remaining remote origin/main, origin/dev, origin/gh-pages