SuperAPI AI Directory

rebase2main

General & other

View repository

Updated 10-16 06:51

About this skill

Rebase to Main

Synchronize the commits of the current development branch to the main branch via rebase, push to the remote, then switch back to the original branch.

Workflow

  1. Record the current branch name

    git branch --show-current
    

    Save the result for later use when switching back. If currently already on the main branch, notify the user and terminate.

  2. Confirm the working tree is clean

    git status
    

If there are uncommitted changes, prompt the user to handle them first (commit or stash), and do not continue.

  1. Switch to the main branch

    git checkout main
    
  2. Rebase dev's commits onto main

    git rebase <原分支名>
    

    If conflicts occur, stop and inform the user that they need to be resolved manually.

  3. Push main to the remote

    git push origin main
    

    Use a normal push, do not use --force. If the push fails, inform the user of the reason.

  4. Switch back to the original branch

    git checkout <原分支名>
    

Notes

  • Do not use --force push, to ensure remote history safety
  • If conflicts occur during the rebase, stop immediately and inform the user
  • Before executing, must confirm the working tree is clean (no uncommitted changes)