mcpField
R
rebase2main

rebase2main

github.com/ruan-catDevelopment557 installsUpdated 5w ago
Repository

About rebase2main

rebase2main is a Git workflow skill for rebasing the current development branch onto main, pushing main to origin, and returning to the original branch. It checks the branch and working-tree state first, and stops for dirty changes or rebase conflicts.

Key features

  1. 01Records the current branch
  2. 02Requires a clean working tree
  3. 03Rebases the branch onto main
  4. 04Pushes main without force
  5. 05Stops on conflicts or push failure

Use cases

  1. 01Updating main with commits from a development branch
  2. 02Checking repository state before a branch update
  3. 03Avoiding force pushes during the update
  4. 04Handling rebase conflicts before proceeding

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/ruan-cat/monorepo --skill rebase2main

After installing, type/rebase2mainin Claude Code to confirm it loaded.

Details

From the project README

Rebase to Main

将当前开发分支的提交以 rebase 方式同步到 main 分支,推送远端,再切回原分支。

工作流程

  1. 记录当前分支名称

    git branch --show-current
    

    将结果保存,后续用于切回。如果当前已在 main 分支,提示用户并终止。

  2. 确认工作树干净

    git status
    

    如果存在未提交的变更,提示用户先处理(提交或暂存),不要继续。

  3. 切换到 main 分支

    git checkout main
    
  4. 将 dev 的提交 rebase 到 main

    git rebase <原分支名>
    

    如果出现冲突,停止并告知用户需要手动解决。

  5. 推送 main 到远端

    git push origin main
    

    使用普通 push,不使用 --force。如果 push 失败,告知用户原因。

  6. 切回原分支

    git checkout <原分支名>
    

注意事项

  • 不使用 --force 推送,保证远端历史安全
  • 如果 rebase 过程中出现冲突,立即停止并告知用户
  • 执行前必须确认工作树干净(无未提交变更)

Comments

Markdown supported