Rebase latest main

From dyoshikawa/rulesync · View interactive version

Rebase latest main is an AI agent skill from the GitHub repository dyoshikawa/rulesync. Fetch latest origin/main and rebase it onto the current branch, resolving conflicts if necessary. Use when the user wants to rebase on main, update their branch with latest main, or sync with upstream.

How to use this skill

Skill file

Rebase Latest Main

Fetch the latest origin/main and rebase it onto the current working branch.

Step 1: Verify Current State

  1. Check the current branch:

```bash

git branch --show-current

```

  1. Ensure there are no uncommitted changes:

```bash

git status --porcelain

```

If there are uncommitted changes, either:

Step 2: Fetch Latest Changes

Fetch the latest changes from the remote:

git fetch origin main

Step 3: Rebase onto origin/main

Start the rebase:

git rebase origin/main

If rebase succeeds without conflicts:

Proceed to Step 5.

If conflicts occur:

  1. Identify conflicting files:

```bash

git diff --name-only --diff-filter=U

```

  1. For each conflicting file:

```bash

git add <resolved-file>

```

  1. Continue the rebase:

```bash

git rebase --continue

```

  1. Repeat until all conflicts are resolved and rebase is complete.

Step 4: Handle Rebase Failure

If unable to resolve conflicts automatically:

```bash

git rebase --abort

```

Step 5: Push Changes

After successful rebase, force push to update the remote branch:

git push --force-with-lease

Note: --force-with-lease is safer than --force as it prevents overwriting others' work.

Step 6: Report Result

Summarize the operation:

  1. Number of commits rebased
  2. Any conflicts that were resolved
  3. Confirmation that the branch is now up-to-date with origin/main
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.