Sync all stacked branches with parents and remotes
Syncs all stacked branches with their parents and remotes using git-machete
/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>Sync all branches in the machete stack with their parents and remotes.
</objective> <workflow>If no machete layout:
AskUserQuestion({
questions: [
{
question: "No git-machete layout. What to do?",
header: "Setup",
options: [
{
label: "Discover layout (Recommended)",
description: "Auto-detect from history",
},
{ label: "Skip", description: "Continue without machete" },
],
multiSelect: false,
},
],
});
If "Discover layout": Skill({ skill: "crew:git:stacked:discover" })
If <worktree_status> shows worktree:
AskUserQuestion({
questions: [
{
question:
"You're in a worktree. Full traverse would switch branches. What to do?",
header: "Worktree",
options: [
{
label: "Update current only (Recommended)",
description: "Run 'git machete update'",
},
{
label: "Show instructions",
description: "Manual steps for each worktree",
},
],
multiSelect: false,
},
],
});
Update current only:
git fetch origin
git machete update
git push --force-with-lease
AskUserQuestion({
questions: [
{
question: "How should traverse handle GitHub PRs?",
header: "PR Sync",
options: [
{ label: "Local only", description: "Just rebase branches locally" },
{
label: "Retarget PRs (Recommended)",
description: "Update PR base branches on GitHub",
},
{
label: "Full sync",
description: "Retarget + update PR descriptions",
},
],
multiSelect: false,
},
],
});
Local only:
git machete traverse -W -y
Retarget PRs:
git machete traverse -W -y -H
Full sync:
git machete traverse -W -y -H
git config machete.github.prDescriptionIntroStyle full
git machete github update-pr-descriptions --related
merged=$(git machete status 2>/dev/null | grep -cE "^\s*o\s" || echo "0")
if [[ "$merged" -gt 0 ]]; then
echo "$merged merged branch(es) detected"
fi
If merged branches:
AskUserQuestion({
questions: [
{
question: "Merged branches detected. Clean them up?",
header: "Cleanup",
options: [
{
label: "Yes (Recommended)",
description: "Slide out merged branches",
},
{ label: "No", description: "Keep them in the layout" },
],
multiSelect: false,
},
],
});
If yes: Skill({ skill: "crew:git:stacked:slide-out" })
| Flag | Effect |
|---|---|
-W | Fetch + traverse entire tree |
-y | Auto-confirm all prompts |
-H | Include GitHub PR retargeting |
-n | No push (rebase only) |
<success_criteria>
</success_criteria>
<notes>Follow @patterns/machete-workflow.md for stacked branch operations.
</notes>