Delete local branches not in machete layout
Deletes local branches not tracked in the machete layout file.
/plugin marketplace add settlemint/agent-marketplace/plugin install crew@settlemintgit/stacked/<butler_context>
!${CLAUDE_PLUGIN_ROOT}/scripts/git/gitbutler-context.sh
</butler_context>
<worktree_status>
!${CLAUDE_PLUGIN_ROOT}/scripts/git/worktree-context.sh 2>&1
</worktree_status>
<stack_context>
!${CLAUDE_PLUGIN_ROOT}/scripts/git/machete-context.sh 2>&1
</stack_context>
<gitbutler_incompatible>
This command does not work with GitButler.
If GITBUTLER_ACTIVE=true from <butler_context>:
Stacked branches (git-machete) are not compatible with GitButler virtual branches.
GitButler has its own stacking system. Use these instead:
- `crew:git:butler:status` - View virtual branches
- `crew:git:butler:branch` - Create virtual branch
- `crew:git:butler:sync` - Sync with upstream
To use machete, first disable GitButler in this repository.
Exit immediately. Do not proceed with machete commands.
</gitbutler_incompatible>
<objective>Clean up local branches that are not tracked in the machete layout file.
</objective> <workflow>echo "=== Branches in machete layout ==="
git machete list managed 2>/dev/null || cat .git/machete
echo
echo "=== Local branches NOT in layout ==="
git machete list unmanaged 2>/dev/null
git machete delete-unmanaged --dry-run
AskUserQuestion({
questions: [
{
question: "Delete the unmanaged branches listed above?",
header: "Delete",
options: [
{
label: "Yes, delete all",
description: "Delete all unmanaged branches",
},
{
label: "Select individually",
description: "Choose which branches to delete",
},
{ label: "No, keep all", description: "Don't delete any branches" },
],
multiSelect: false,
},
],
});
Delete all:
git machete delete-unmanaged --yes
Delete specific:
git branch -d <branch-name> # Safe
git branch -D <branch-name> # Force
git fetch --prune
git branch -vv | grep ': gone]'
echo "=== Remaining branches ==="
git branch -a
echo
git machete status
</workflow>
<success_criteria>
</success_criteria>