| name | Update from Main |
| description | Updates the current branch with the latest changes from origin/main using rebase. Use when the user asks to update, sync, or rebase their branch with main/master. |
Update from Main
This skill helps update the current branch with the latest changes from origin/main using git rebase.
Quick Start
When the user requests to update their branch with main:
- Check the current branch name
- Ensure working directory is clean (no uncommitted changes)
- Fetch latest changes from origin
- Rebase current branch onto origin/main
- Handle any conflicts that arise
Instructions
Step 1: Check current state
# Get current branch name
git branch --show-current
# Check for uncommitted changes
git status
If there are uncommitted changes, ask the user if they want to:
- Commit them first
- Stash them
- Abort the operation
Step 2: Fetch latest changes
# Fetch all latest changes from origin
git fetch origin
Step 3: Rebase onto origin/main
# Rebase current branch onto origin/main
git rebase origin/main
Step 4: Handle conflicts
If conflicts occur during rebase:
- Show the conflicting files:
git status
Inform the user about the conflicts and list the files
Explain that they need to:
- Resolve conflicts manually
- Run
git add <file>for each resolved file - Run
git rebase --continue - Or run
git rebase --abortto cancel
Offer to help resolve conflicts if the user requests it
Step 5: Confirm success
After successful rebase:
# Show the updated status
git status
# Show recent commits to verify
git log --oneline -5
Inform the user that:
- The branch has been successfully updated with changes from origin/main
- If the branch was previously pushed, they may need to force push:
git push --force-with-lease
Important Notes
- Always check for uncommitted changes before starting
- Use
git rebase --abortif something goes wrong - Prefer
git push --force-with-leaseovergit push --forcefor safety - If the user prefers merge over rebase, use
git merge origin/maininstead
Alternative: Merge instead of Rebase
If the user explicitly prefers merge or if rebase fails repeatedly:
git fetch origin
git merge origin/main
This creates a merge commit instead of rewriting history.
Common Issues
- "cannot rebase with uncommitted changes": Stash or commit changes first
- Conflicts during rebase: Help user resolve them or abort and try merge
- Already up to date: Inform user no changes were needed