Skip to content
Agentmart
Submit a tool

rebase-origin-main

Rebase the current feature branch onto the latest origin/master, triage conflicts by severity, then force-with-lease push with an explicit refspec.

Skill by asura1234

IndexedApache-2.0★ 1
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/asura1234-rebase-origin-main

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

Rebase the current feature branch onto the latest origin/master, triage conflicts by severity, then force-with-lease push with an explicit refspec. Use when the user asks to "rebase", "sync master", "update to the latest master", "rebase onto origin/master", or "resolve conflicts and push". Agent-agnostic (claude / cursor / codex); pure git plus cargo for Cargo.lock.

Use cases: agent-building

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/rebase-origin-main

What's inside

Skill name
rebase-origin-main
Description
Rebase the current feature branch onto the latest origin/master, triage conflicts by severity, then force-with-lease push with an explicit refspec. Use when the user asks to "rebase", "sync master", "update to the latest master", "rebase onto origin/master", or "resolve conflicts and push". Agent-agnostic (claude / cursor / codex); pure git plus cargo for Cargo.lock.
License
Apache-2.0
Instructions
160 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

Resolve `SKILL_DIR` to the directory containing this loaded SKILL.md; keep the working directory in the target repository.
# Rebase onto origin/master

Rebase the current branch onto the latest `origin/master`, resolve conflicts, then force push.
Pure git; runnable by any AI agent.

```
-- Guard: refuse detached HEAD and protected branches (main / master)
--   Same guard as `commit-and-push`: these are the protected branches in Bus.
-- Remote: always `origin` (the Bus fork). Never fetch from, rebase onto, or push to `upstream`.

-- Rules
- Auto-resolve minor conflicts (imports, formatting, non-overlapping regions, docs/comments)
- Ask developer for major conflicts (same function modified both sides, signature changes,
  logic conflicts, delete-vs-modify)
- Shared infra always takes the origin/master version on conflict; never merge it by hand:
    `Cargo.lock`
  The only regeneration allowed is cargo re-adding the entries this branch's own Cargo.toml
  still needs on top of origin/master's lockfile (see RESOLVE CONFLICTS); no `cargo update`.
  The cost is explicit: this drops this branch's own lockfile-only bumps. So every hit must be
  recorded in `dropped_shared_infra` and listed one by one in the final output, so the developer
  knows whether to redo it -- dropping is fine, dropping silently is not.

========== VALIDATE ==========

rebase_root = the single existing path from
  `git rev-parse --git-path rebase-merge` / `git rev-parse --git-path rebase-apply`

IF rebase_root exists:
  branch = strip `refs/heads/` from `<rebase_root>/head-name`
  IF branch empty
    ERROR "A rebase is in progress, but it has no named branch (rebase on a detached HEAD). Finish it manually."
  -- The resume path never gets a chance to record the old HEAD before the rebase, so read the
  --   orig-head the rebase itself stored. PUSH's divergence check needs it; without it there is no way
  --   to separate "my own commits before rewriting" from "commits someone else pushed".
  -- orig-head is a plain file holding one sha, not a ref: read its contents directly; `git rev-parse` cannot resolve it.
  pre_rebase_head = contents of `<rebase_root>/orig-head` (one 40-char sha)
  IF that file is missing or its contents are not a valid commit (verify with `git cat-file -e <sha>^{commit}`)
    ERROR "Cannot get the pre-rebase HEAD (<rebase_root>/orig-head missing or corrupt). Finish manually, then rerun."
  Do not fetch and do not start a second rebase.
ELSE:
  branch = `git branch --show-current`
  IF branch empty
    ERROR "Rebase is not allowed on a detached HEAD. Switch to a named feature branch first."

-- The protected-branch guard applies equally to both entry paths. The resume path also ends in the
--   final force push; checking only inside ELSE would let "a rebase paused on master" bypass the guard
--   and rewrite a protected branch directly.
IF branch IN {main, master}
  ERROR "Rebasing or rewriting history is not allowed on main/master."

IF rebase_root exists:
  Continue at `RESOLVE CONFLICTS` using the existing paused index/worktree.

========== FETCH & REBASE ==========

`git fetch origin`
Assert `origin/master` resolves.

IF `git rev-list --count origin/master..HEAD` == 0
  Print "The current branch has no commits of its own relative to origin/master."
  -- Still continue: the branch may just be behind master, and the rebase is a fast-forward.

-- Must be recorded before the rebase; PUSH's divergence check uses it to exclude "my own commits before rewriting".
--   Do not switch PUSH to reading ORIG_HEAD: it is a global single slot, and any merge/reset/pull
--   in between overwrites it.
pre_rebase_head = `git rev-parse HEAD`

`git rebase origin/master`

IF no conflicts → skip to PUSH

========== RESOLVE CONFLICTS ==========

dropped_shared_infra = []

FOR EACH conflicted file (`git diff --name-only --diff-filter=U`)
  Read the file to understand both sides

  IF file is `Cargo.lock`
    -- During a rebase ours/theirs are reversed: --ours = origin/master (the base being replayed onto),
    --   --theirs = your own commit being replayed. So "take the origin/master version" is --ours.
    --   Do not hand-edit it.
    `git checkout --ours -- Cargo.lock`
    -- If this branch's Cargo.toml adds or changes dependencies, origin/master's lockfile lacks them.
    --   `cargo metadata` resolves only what is missing and writes it back, without upgrading
    --   anything already locked. Never run `cargo update` here.
    `cargo metadata --format-version 1 > /dev/null`
    `git add Cargo.lock`
    append Cargo.lock to dropped_shared_infra

  ELSE IF minor conflict (import order, whitespace, formatting, non-overlapping edits, docs/comments)
    Resolve automatically
    `git add <file>`

  ELSE (same function/method modified by both sides, signature changes, logic conflicts,
        delete-vs-modify, uncertain)
    Show conflict content to developer
    AskUserQuestion — how to resolve?
    Apply developer's choice
    `git add <file>`

`git rebase --continue`
REPEAT until rebase completes

-- After taking origin/master's shared infra, this branch's commit may become entirely empty. git drops it
--   by default (a commit that only bumped Cargo.lock, once taken as origin/master, no longer appears in log
--   after the rebase completes).
--   If git instead stops and asks for confirmation, use `git rebase --skip`; do not create an empty commit.

========== PUSH ==========

IF `origin/<branch>` does not exist
  -- The branch was never pushed; there is nothing on the remote to erase, so no force and no divergence check.
  `git push -u origin <branch>:<branch>`
  Skip the rest of this section.

remote_tip = `git rev-parse origin/<branch>`

-- ⚠️ Do not use `git rev-list --count HEAD..origin/<branch>` to detect divergence. A rebase always rewrites

From asura1234/bus, Apache-2.0.

More from asura1234/bus

Signals

Stars
1
Forks
0
Open issues
0
Last commit (this folder)
Oct 6, 2026 (24 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from asura1234

Cite this page

rebase-origin-main skill. Agent Mart. https://agentmart.dev/skills/asura1234-rebase-origin-main (last updated 2026-10-24)