一键导入
clean-local-branches
Clean up local branches which have been merged into the default branch, and rebase unmerged branches.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Clean up local branches which have been merged into the default branch, and rebase unmerged branches.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | clean-local-branches |
| description | Clean up local branches which have been merged into the default branch, and rebase unmerged branches. |
This skill helps the user clean up local branches that have already been merged into the default branch (e.g., main or master) and rebases branches which have not.
main or master).git fetch --prune to update remote refs and remove stale remote tracking branches.For each local branch (excluding the default branch and other protected branches like develop):
git checkout <branch>git rebase <default>git rebase --abort) and note the branch as Conflict.git rev-parse HEAD vs git rev-parse <default>). If they match, the branch is Merged — all its commits were already applied, so rebase dropped them and the tip landed on the default branch. Otherwise, the branch is Rebased (it has commits on top of the default branch).Also note whether each branch has a remote tracking branch (i.e. origin/<branch> exists). This information is needed in Step 5.
Return to the default branch when done.
This approach reliably detects standard merges, squash merges, and cherry-picks, because rebase drops commits whose changes are already present in the default branch. As a bonus, unmerged branches get rebased onto the latest default branch.
Present the results in a clear table, for example:
| Branch | Status | Proposed Action |
|-----------------|----------|-----------------|
| feature/foo | Merged | Delete (local + remote) |
| feature/bar | Merged | Delete (local only) |
| bugfix/baz | Rebased | Force push |
| experiment/qux | Rebased | Keep (no remote) |
| hotfix/abc | Conflict | Keep (needs manual resolution) |
Ask the user to confirm which merged branches to delete.
git branch -D <branch>. If the branch also exists on the remote, delete it with git push origin --delete <branch>.git push --force-with-lease origin <branch>. If it does not exist on the remote, do nothing (do not push).