Sync current branch with the base branch (main/master) using rebase or merge.
Keeps your feature branch up to date with the base branch by rebasing or merging.
/sync # Rebase on main/master (default)
/sync --merge # Merge main/master into branch
/sync --base develop # Sync with specific branch
| Argument | Description | Default |
|----------|-------------|---------|
| --merge | Use merge instead of rebase | false (rebase) |
| --base | Base branch to sync with | main or master |
| --repo | Specific repo to sync (multi-repo only) | All repos |
| --parallel | Sync repos in parallel | false |
| Strategy | Pros | Cons | |----------|------|------| | Rebase (default) | Clean linear history, easier to review | Rewrites history, can cause issues if branch is shared | | Merge | Preserves history, safe for shared branches | Creates merge commits, messier history |
Recommendation:
# Ensure we're on a feature branch
CURRENT_BRANCH=$(git branch --show-current)
# Check for uncommitted changes
git status --porcelain
If uncommitted changes exist:
git stash push -m "Auto-stash before sync"git stash popgit fetch origin
# Use provided base or detect default
if [ -n "$BASE_ARG" ]; then
BASE_BRANCH="$BASE_ARG"
else
BASE_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
[ -z "$BASE_BRANCH" ] && BASE_BRANCH="main"
fi
git rebase origin/$BASE_BRANCH
If conflicts occur:
git diff --name-only --diff-filter=UAfter successful rebase:
# Force push is needed after rebase
git push --force-with-lease origin $CURRENT_BRANCH
git merge origin/$BASE_BRANCH -m "Merge $BASE_BRANCH into $CURRENT_BRANCH"
If conflicts occur:
git commitAfter successful merge:
git push origin $CURRENT_BRANCH
git stash pop
If stash pop conflicts:
## Branch Synced
**Branch:** `feature/user-auth`
**Base:** `main`
**Strategy:** rebase
### Changes Incorporated
- abc1234 feat: add new API endpoint
- def5678 fix: resolve login issue
### Status
- Conflicts: None
- Push: Completed (force-with-lease)
When conflicts occur:
git diff --name-only --diff-filter=U
# For rebase
git add <resolved-files>
git rebase --continue
# For merge
git add <resolved-files>
git commit
git rebase --abort # or git merge --abort
Report to user with details.
When rebasing requires force push:
# Use --force-with-lease to prevent overwriting others' work
git push --force-with-lease origin $CURRENT_BRANCH
If force-with-lease fails:
Always stash before sync to prevent losing work:
git stash push -m "Auto-stash before sync $(date +%Y%m%d-%H%M%S)"
List stashes if pop fails:
git stash list
| Error | Action | |-------|--------| | Uncommitted changes | Auto-stash, restore after | | Conflicts during rebase | Help resolve or abort | | Conflicts during merge | Help resolve or abort | | Force push rejected | Report, suggest coordination | | Stash pop conflicts | Report, keep in stash | | Not on feature branch | Warn, suggest creating branch |
/sync
Rebases current branch on main, force-pushes.
/sync --merge
Merges main into current branch, regular push.
/sync --base develop
Syncs with develop instead of main.
This skill is automatically called by /ship when push fails due to upstream changes. Users can also invoke it manually to keep branches fresh during long-running work.
For workspaces with multiple repositories, /sync coordinates syncing across all repos.
Uses the same configuration as /branch in .claude/settings.json:
{
"pm": {
"multi_repo": {
"enabled": true,
"repositories": {
"workspace": ".",
"backend": "./backend",
"web": "./web",
"mobile": "./mobile"
}
}
}
}
--repo specified, sync only that repo# Check which repos are on the feature branch
for repo in $REPOS; do
BRANCH=$(cd $repo && git branch --show-current)
if [ "$BRANCH" = "$FEATURE_BRANCH" ]; then
echo "$repo: on $BRANCH"
fi
done
For each target repo, execute the standard sync workflow:
for repo in $REPOS; do
(
cd $repo
git stash push -m "Auto-stash before sync"
git fetch origin
git rebase origin/$BASE_BRANCH # or merge
git push --force-with-lease origin $BRANCH
git stash pop
)
done
With --parallel, sync repos concurrently:
# Sync in background
(cd backend && git fetch && git rebase origin/main) &
(cd web && git fetch && git rebase origin/main) &
(cd mobile && git fetch && git rebase origin/main) &
wait
Note: Parallel sync is faster but makes conflict resolution harder.
## Branches Synced
| Repository | Branch | Strategy | Status | Conflicts |
|------------|--------|----------|--------|-----------|
| backend | `feature/user-auth` | rebase | Synced | None |
| web | `feature/user-auth` | rebase | Synced | None |
| mobile | `feature/user-auth` | rebase | Synced | 1 file |
### Conflict Details (mobile)
- `src/api/auth.ts` - Manual resolution needed
### Changes Incorporated
**backend:**
- abc1234 feat: add user model
**web:**
- def5678 fix: update API client
### Next Steps
1. Resolve conflict in mobile/src/api/auth.ts
2. Run `/sync --repo mobile` to complete
When conflicts occur in multi-repo sync:
Stop at first conflict (default)
Continue on conflict (with flag)
/sync
Rebases all repos on their respective main branches.
/sync --repo backend
Only syncs the backend repo.
/sync --parallel
Syncs all repos concurrently (faster, but harder to debug).
/sync --merge
Uses merge instead of rebase in all repos.
| Error | Action | |-------|--------| | Conflict in one repo | Stop, help resolve, offer to continue | | Force push rejected | Report which repo, suggest coordination | | Repo not on feature branch | Skip that repo, report | | Stash pop conflicts | Keep in stash, report per repo |
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer