Git rebase sync

From alleneubank/claude-code · View interactive version

Git rebase sync is an AI agent skill from the GitHub repository alleneubank/claude-code. Use when syncing a feature branch onto the latest origin base branch via git rebase.

How to use this skill

Skill file

git-rebase-sync

Use this skill when you need to sync a feature branch onto the latest origin/{base_branch} via git rebase, including conflict resolution with explicit clarification questions when intent is ambiguous.

Goals

Hard Rules

Workflow

1) Identify base + branch

2) Preflight safety checks

3) Create a local backup ref (do not push)

4) Choose rebase mode (normal vs preserve merges)

5) Detect stacked branches (will they follow the rebase?)

Other local branches may point at intermediate commits in the range being rewritten (origin/{base_branch}..HEAD) — common with phased NN-description stacks. A plain rebase rewrites those commits and orphans the stacked branches on the old, pre-rebase commits (along with every open PR built on them). --update-refs (the default in step 6) moves them onto the rewritten commits instead. Enumerate them so you can report what the rebase will carry along:

# Branches pointing into the range being rewritten — these get orphaned by a
# plain rebase and require --update-refs to follow the rewrite.
cur=$(git branch --show-current)
git for-each-ref --format='%(refname:short)' refs/heads | while read -r br; do
  [ "$br" = "$cur" ] && continue
  if git merge-base --is-ancestor "$br" HEAD \
     && ! git merge-base --is-ancestor "$br" origin/{base_branch}; then
    echo "stacked: $br ($(git rev-parse --short "$br"))"
  fi
done

6) Run the rebase (requires confirmation)

7) Conflict handling loop

When conflicts happen:

  1. Collect context:
  1. For each conflicted file:
  1. Apply the resolution, then stage only resolved files:
  1. Continue:
  1. If you reach a point where resolution is too risky/unclear:

Helpful commands during conflicts:

8) Post-rebase verification

9) Push updated branch(es) (requires confirmation)

Recovery

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.