Fast-forward merge child into current branch, slide out child, and update PRs
Fast-forward merge child branch into current, slide out child, and update PRs
/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>Fast-forward merge a child branch into current branch, then slide out the child.
</objective> <workflow>current=$(git branch --show-current)
children=$(git machete show down 2>/dev/null || echo "")
if [[ -z "$children" ]]; then
echo "No child branches to advance into $current"
exit 1
fi
echo "Current: $current"
echo "Child: $children"
child=$(git machete show down | head -1)
if git merge-base --is-ancestor "$current" "$child" 2>/dev/null; then
echo "Fast-forward merge is possible"
else
echo "Fast-forward not possible - child has diverged"
fi
If not fast-forward:
AskUserQuestion({
questions: [
{
question: "Fast-forward not possible. What to do?",
header: "Diverged",
options: [
{
label: "Rebase child first",
description: "Run git machete update on child",
},
{ label: "Cancel", description: "Keep branches separate" },
],
multiSelect: false,
},
],
});
AskUserQuestion({
questions: [
{
question:
"Advance will merge child into current and slide out child. Continue?",
header: "Confirm",
options: [
{
label: "Yes (Recommended)",
description: "Fast-forward merge and slide out",
},
{ label: "No", description: "Cancel advance" },
],
multiSelect: false,
},
],
});
git machete advance --yes
AskUserQuestion({
questions: [
{
question: "Push the advanced branch?",
header: "Push",
options: [
{ label: "Yes", description: "Push to origin" },
{ label: "Force push", description: "Push with --force-with-lease" },
{ label: "No", description: "Don't push yet" },
],
multiSelect: false,
},
],
});
If push: git push origin $(git branch --show-current)
If force push: git push --force-with-lease origin $(git branch --show-current)
if git machete is-managed "$(git branch --show-current)" 2>/dev/null; then
git config machete.github.prDescriptionIntroStyle full
git machete github anno-prs
git machete github update-pr-descriptions --related
fi
git machete status --list-commits
</workflow>
<success_criteria>
</success_criteria>