About clean-gone-branches
A Git cleanup skill that removes local branches whose remote counterparts are gone, checking and removing associated worktrees first. It is for keeping a repository’s local branch list aligned with remote state.
Key features
- 01Prune remote references
- 02Find branches marked gone
- 03Check worktrees for affected branches
- 04Remove worktrees before branches
- 05Report cleanup results
Use cases
- 01Clean up branches deleted from a remote
- 02Remove worktrees tied to gone branches
- 03Confirm when no cleanup is needed
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ fcakyon/ claude-codex-settings --skill clean-gone-branchesAfter installing, type/clean-gone-branchesin Claude Code to confirm it loaded.
Details
From the project READMEClean Gone Branches
Remove local git branches that have been deleted from the remote.
Process
-
Update remote references
- Run
git fetch --prune.
- Run
-
Inspect local state
- Run
git branch -vvto find branches marked as[gone]. - Run
git worktree listto see whether any of those branches still have worktrees.
- Run
-
Remove worktrees first
- For each
[gone]branch that still has a worktree, remove the worktree before deleting the branch.
- For each
-
Delete the gone branches
- Delete each local branch marked as
[gone].
- Delete each local branch marked as
-
Report the result
- List removed worktrees and deleted branches.
- If there are no
[gone]branches, report that nothing needed cleanup.
Comments
Markdown supported