Git Rebase Main

SkillProductivity

Land a finished branch on local main with linear history, commit pending work, commit main's own dirt first, rebase onto main, fast-forward main. Use when the user asks to rebase/merge/合回主分支 into local main after work is committed. Local only, never touches remotes.

Instructions available. Your AI can read the instructions. Execution depends on the setup they require.

Add ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.

Then ask your AI: use the Git Rebase Main skill

What this skill tells your AI

The instructions your AI receives, as published by dimon94/skills in skills/git-rebase-main/SKILL.md and read by ahel’s review.

Land the current branch on local main with linear history. Local only: never push, never fetch, never delete the branch afterward.

1. Commit pending work here

If the current worktree is dirty, commit it per the git-commit skill.

2. Already on main → done

If the current branch is main, that commit was the landing. Report and stop.

3. Commit main's own dirt first

Locate main's worktree with git worktree list --porcelain. If main is checked out somewhere and that worktree is dirty, commit it there per the git-commit skill — before the rebase, because that commit advances main and the branch must rebase onto the advanced head.

4. Rebase onto main

git rebase main. On conflict, apply the resolving-merge-conflicts skill; never --abort.

5. Advance main to the rebased head

  • main checked out in a worktree → run git merge --ff-only <branch> there.
  • main not checked out anywhere → run git branch -f main <branch> here.

If the merge is not fast-forward, stop and report. Do not force anything.

6. Report

New main head, commits landed, where dirt was committed (if any), and that the source branch was left intact.

Signals

GitHub stars
108
Forks
21
Last commit
Sep 2026
Advanced
Item type
skill
Key
git-rebase-main
Source
github.com/dimon94/skills