Get the FREE Ultimate OpenClaw Setup Guide →

rebase-merged-parent

npx machina-cli add skill flurdy/agent-skills/rebase-merged-parent --openclaw
Files (1)
SKILL.md
2.3 KB

Rebase After Parent Merged to Main

Rebase your branch onto main after the parent PR it was based on has been merged.

Usage

/rebase-merged-parent
/rebase-merged-parent feature/old-parent    # Specify the old parent branch

Instructions

1. Understand the Situation

Your branch was based on a parent branch (not main). That parent PR has now been merged to main. You need to:

  • Rebase onto main
  • Keep only YOUR commits (not the parent's commits, which are now in main)
  • Update the PR to target main instead of the old parent

2. Identify the Old Parent Branch

If not provided:

# Check what the PR is currently targeting
gh pr view --json baseRefName --jq '.baseRefName'

If the base is already main, ask the user which branch was the old parent.

3. Check Current State

git status --porcelain
git branch --show-current

Stash or commit uncommitted changes.

4. Fetch Latest Main

git fetch origin main

5. Find Your Commits

Identify which commits are uniquely yours (not from the merged parent):

# List commits on your branch not in main
git log origin/main..HEAD --oneline

# These should only be YOUR commits if parent was merged properly
# If you see parent's commits too, we need to be more selective

6. Rebase onto Main

Since the parent is now in main, rebasing onto main should work cleanly:

git rebase origin/main

If there are duplicate commits (your commits that conflict with the parent's merged version), git may skip them automatically or you may need to resolve conflicts.

7. Handle Conflicts or Duplicates

If git reports "already applied" commits:

  • These are likely parent commits that are now in main
  • They'll be skipped automatically

If real conflicts:

  1. Resolve each conflict
  2. git add {file}
  3. git rebase --continue

8. Force Push

git push --force-with-lease

9. Update PR Base to Main

gh pr edit --base main

10. Report Result

Inform the user:

  • Rebased onto main (parent was merged)
  • Updated PR to target main
  • X commits remain after rebase
  • Force pushed to origin

Source

git clone https://github.com/flurdy/agent-skills/blob/main/skills/rebase-merged-parent/SKILL.mdView on GitHub

Overview

Rebase your feature branch onto main after the parent PR it relied on has merged. This keeps only your commits on top of main and updates the PR to target main, avoiding duplicated merged changes. It's useful when you stacked on a parent PR that's now in main.

How This Skill Works

The skill identifies the old parent, fetches latest main, and isolates your unique commits. It performs git rebase origin/main to place your work on top of main, skipping any duplicates from the merged parent. If conflicts arise, you resolve them and continue, then force-push and update the PR base to main.

When to Use It

  • Your branch was based on a parent PR that has now merged to main.
  • You need to rebalance onto main while keeping only your commits.
  • You want to update the PR base from the old parent to main.
  • The base of your PR is not main and needs to be switched to main.
  • You encounter duplicate or already-applied commits during rebase and need guidance.

Quick Start

  1. Step 1: Run /rebase-merged-parent [old-parent] to start or omit to auto-detect.
  2. Step 2: If prompted, specify the old parent; fix conflicts if any and complete the rebase.
  3. Step 3: git push --force-with-lease and gh pr edit --base main to update the PR target.

Best Practices

  • Always determine the old parent branch with gh pr view or by inspecting the PR.
  • Ensure a clean working tree (stash or commit changes) before starting.
  • Review the commit history with git log origin/main..HEAD to confirm you only have your commits.
  • Run git rebase origin/main and be prepared to skip already-applied duplicates or resolve conflicts.
  • Push with git push --force-with-lease and update the PR base to main afterward.

Example Use Cases

  • Feature: add user profile tabs was stacked on parent PR feat/ui-base merged to main.
  • Refactor: optimize search results pipeline, branched on parent PR feat/search-base merged to main.
  • UI: update theme color that depended on a merged parent, rebased to main.
  • Backend: add API rate limiter on top of parent PR feat/api-base now in main.
  • Docs: update changelog entries; branch based on a merged parent PR and rebased to main.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers