Skip to content
Agentmart
Submit a tool

stacked-branches

Guide for managing stacked MRs with git-branchless.

Skill by bgschiller

IndexedUnlicense
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/bgschiller-stacked-branches

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Guide for managing stacked MRs with git-branchless. Use when working with stacked branches, restacking commits, or pushing multiple related branches.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/stacked-branches

What's inside

Skill name
stacked-branches
Description
Guide for managing stacked MRs with git-branchless. Use when working with stacked branches, restacking commits, or pushing multiple related branches.
License
Unlicense
Instructions
134 lines in SKILL.md · view on GitHub

Agent Skills spec issues

  • allowed-tools: must be a space-separated string

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Stacked Branches with git-branchless

Manage stacked merge requests using git-branchless.

## Key Concepts

A **stack** is a chain of branches where each depends on the previous one. Instead of one large MR, you create multiple small, focused MRs that build on each other:

```
main
  └── feature-part-1 (MR !1 → main)
        └── feature-part-2 (MR !2 → feature-part-1, blocks on !1)
              └── feature-part-3 (MR !3 → feature-part-2, blocks on !2)
```

Benefits:
- Smaller, easier-to-review MRs
- Parallel work while waiting for reviews
- Logical grouping of related changes

## Orientation: See Your Stack

```bash
# Show commits in the current stack
git sl                    # Short alias
git smartlog 'stack()'    # Full command

# Show all branches in the stack
git query -b 'stack()'
```

## Navigation

```bash
git sw <branch>    # Switch to a branch
git prev           # Move to parent commit
git next           # Move to child commit (prompts if multiple)
```

## Adding Commits Mid-Stack

When you need to add a commit somewhere in the middle of a stack:

### Preferred: `git record --insert`

```bash
# Navigate to where you want the commit
git sw feature-part-1

# Stage changes and create commit
# --insert automatically restacks all descendants
git record --insert -m "Add missing validation"
```

### Alternative: Amend + Restack

```bash
# Navigate and amend
git sw feature-part-1
git commit --amend

# Manually rebase descendants onto the amended commit
git restack
```

## Moving Commits

```bash
# Move a commit (or range) to a different location
git move --source <commit> --dest <commit>

# Move entire stack to updated main
git move --source 'stack()' --dest main --merge
```

### Fix Branches After `git move --merge`

After `git move --merge`, branches may point to old commits instead of the rebased ones:

```bash
git move-branches        # Detect and fix misplaced branches
git move-branches -n     # Dry run: show what would change
```

This script finds duplicate commit messages in the stack (old vs rebased) and moves branches to the newer commits.

## Pushing the Stack

```bash
# Push all changed branches with --force-with-lease
git submit
```

This pushes every branch in the stack that has local changes, using force-with-lease for safety.

## Creating Stacked MRs

When creating MRs for stacked branches, use `git merge-target` to find the correct target:

```bash
git merge-target
# Returns: the parent branch name, or "main" if at stack root
```

**Blocking relationships**: When an MR targets a branch other than `main`, set up a blocking dependency so the parent MR must merge first. See the `create-mr` skill for details.

## Useful Query Patterns

```bash
# All commits in the stack
git query 'stack()'

# Branches in the stack
git query -b 'stack()'

# Ancestors of HEAD that are also in the stack's parent
git query 'ancestors(HEAD) & parents(stack())'
```

From bgschiller/dotfiles, Unlicense.

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Jun 3, 2026 (4 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Unlicense
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from bgschiller

Cite this page

stacked-branches skill. Agent Mart. https://agentmart.dev/skills/bgschiller-stacked-branches (last updated 2026-10-24)