Sync all stacked branches with parents and remotes
/plugin marketplace add settlemint/agent-marketplace/plugin install crew@settlemintgit/<worktree_status>
!${CLAUDE_PLUGIN_ROOT}/scripts/git/worktree-context.sh
</worktree_status>
<stack_context>
!${CLAUDE_PLUGIN_ROOT}/scripts/git/machete-context.sh
</stack_context>
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: "Create manually", description: "Open editor" },
{ label: "Skip", description: "Continue without machete" },
],
multiSelect: false,
},
],
});
If "Discover layout":
Skill({ skill: "crew:git:discover" });
If in a WORKTREE:
â ď¸ Full traverse would switch branches, breaking this worktree's checkout.
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' for this branch",
},
{
label: "Show instructions",
description: "Manual steps for each worktree",
},
],
},
],
});
Update current only:
git fetch origin
git machete update # Rebase onto parent
git push --force-with-lease # Push updated branch
Show instructions:
Print for each branch in stack:
To sync your stack across worktrees:
1. In worktree for <parent-branch>:
git pull --rebase origin main
git push
2. In worktree for <child-branch>:
git machete update
git push --force-with-lease
3. Repeat for each child...
If in MAIN checkout (not a worktree):
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
# Ensure config is set for update-pr-descriptions
git config machete.github.prDescriptionIntroStyle full
# Update all related PR descriptions with stack chain
git machete github update-pr-descriptions --related
After traverse completes, check for merged branches:
# Check for merged branches (gray edges)
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 found:
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:slide-out" });
Report: branches rebased, pushed, needing manual intervention.
</process> <flags>| Flag | Effect |
|---|---|
-W | Fetch + traverse entire tree (whole) |
-y | Auto-confirm all prompts (yes) |
-H | Include GitHub PR retargeting (github-sync) |
-n | No push (rebase only, don't push) |
-M | Detect merged branches and suggest slide-out |
--start-from=<branch> | Start traverse from specific branch |
--return-to=<branch> | Return to branch after traverse |
<common_patterns>
Daily sync workflow:
# Full sync with PR updates
git machete traverse -W -y -H
Quick local rebase:
# No push, no GitHub sync
git machete traverse -W -y -n
After parent PR merged:
# Slide out merged, then traverse
Skill({ skill: "crew:git:slide-out" })
git machete traverse -W -y -H
Sync and cleanup:
git machete traverse -W -y -H -M
</common_patterns>