Clean up local branches deleted from remote
Removes local branches that were deleted from remote and their associated worktrees. Use this to clean up stale branches after team members delete remote branches.
/plugin marketplace add fcakyon/claude-codex-settings/plugin install slack-tools@claude-settingsRemove local git branches that have been deleted from remote (marked as [gone]).
Run the following commands in sequence:
Update remote references:
git fetch --prune
View branches marked as [gone]:
git branch -vv
List worktrees (if any):
git worktree list
Remove worktrees for gone branches (if any):
git branch -vv | grep '\[gone\]' | awk '{print $1}' | sed 's/^[*+]*//' | while read -r branch; do
worktree=$(git worktree list | grep "\[$branch\]" | awk '{print $1}')
if [ -n "$worktree" ]; then
echo "Removing worktree: $worktree"
git worktree remove --force "$worktree"
fi
done
Delete gone branches:
git branch -vv | grep '\[gone\]' | awk '{print $1}' | sed 's/^[*+]*//' | xargs -I {} git branch -D {}
Report the results: list of removed worktrees and deleted branches, or notify if no [gone] branches exist.