agentleFS
CarpeWuCarpeWu/claude-git-skills/skills/git-cleanup/SKILL.md

git-cleanup

Skill0 starsChanged 10 months agoMITView on GitHub

Cleans up merged Git branches safely. Use when cleaning up old branches, deleting merged branches, or maintaining repository hygiene.

  • Commits and pushes

11 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use skill-creator.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • SentrySkill

    skill-creator

    Create new agent skills following the Agent Skills specification. Use when asked to "create a skill", "add a new skill", "write a skill", "make a skill", "build a skill", or scaffold a new skill with SKILL.md. Guides through requirements, writing, registration, and verification.

    Also in 4 projects that use this

The file

Files
SKILL.md

Git Cleanup

清理已合并的分支

Context

  • 当前分支: !git branch --show-current
  • 本地分支: !git branch
  • 已合并到 develop: !git branch --merged develop 2>/dev/null
  • 已合并到 main: !git branch --merged main 2>/dev/null
  • 远程分支: !git branch -r | head -30

Protected Branches

以下分支永远不删除:

  • main
  • master
  • develop
  • dev
  • release/*(当前活跃的)

Workflow

Step 1: 扫描分支

分析可清理的分支:

🧹 分支清理扫描

📋 可安全删除的分支(已合并):

本地分支:
  ✓ feature/old-feature      (合并于 2025-01-20)
  ✓ bugfix/login-fix         (合并于 2025-01-18)

远程分支:
  ✓ origin/feature/old-feature
  ✓ origin/bugfix/login-fix

🔒 保护分支(不删除):
  • main
  • develop

⚠️ 未合并分支(跳过):
  • feature/work-in-progress

Step 2: 确认删除

🗑️ 将删除以下分支:

本地: 2 个
  • feature/old-feature
  • bugfix/login-fix

远程: 2 个
  • origin/feature/old-feature
  • origin/bugfix/login-fix

请选择操作:
  • 输入 "all" → 删除所有
  • 输入 "local" → 仅删除本地
  • 输入 "remote" → 仅删除远程
  • 输入分支名 → 删除指定分支
  • 输入 "cancel" → 取消

Step 3: 执行删除

# 删除本地分支
git branch -d feature/old-feature
git branch -d bugfix/login-fix

# 删除远程分支
git push origin --delete feature/old-feature
git push origin --delete bugfix/login-fix

# 清理远程引用
git fetch --prune

Step 4: 输出结果

✅ 分支清理完成!

🗑️ 已删除:
├─ 本地: 2 个分支
│  • feature/old-feature
│  • bugfix/login-fix
└─ 远程: 2 个分支
   • origin/feature/old-feature
   • origin/bugfix/login-fix

🔒 保留:
├─ main
├─ develop
└─ feature/work-in-progress (未合并)

💡 提示: 使用 git fetch --prune 定期清理远程引用

Safety Measures

  1. 只删除已合并分支:使用 git branch --merged
  2. 保护核心分支:main/develop 永不删除
  3. 确认后执行:不自动删除,等待用户确认
  4. 使用 -d 而非 -D:-d 只删除已合并分支,更安全

Error Handling

情况处理
无可清理分支✨ 没有需要清理的分支,仓库很整洁!
删除当前分支❌ 无法删除当前分支,请先切换到其他分支
远程删除失败继续删除其他,最后汇报失败的分支

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.