A Claude Code slash command for syncing forked repositories with upstream changes.
# Clone to your preferred location
git clone git@github.com:claude-commands/command-sync-fork.git <clone-path>/command-sync-fork
# Symlink (use full path to cloned repo)
ln -s <clone-path>/command-sync-fork/sync-fork.md ~/.claude/commands/sync-fork.md/sync-fork # Sync default branch with upstream
/sync-fork --rebase # Rebase local changes on upstream
/sync-fork --all # Sync all tracking branches
/sync-fork --dry-run # Show what would be synced
/sync-fork develop # Sync specific branch
- Detects upstream remote (adds if missing)
- Fetches upstream changes
- Analyzes divergence between fork and upstream
- Merges or rebases onto local branch
- Pushes updated branch to origin
Fork Sync Complete
Branch: main
Strategy: Merge
Commits Added: 15
Changes from Upstream:
| Category | Files | Lines |
| -------- | ----- | ----------- |
| Added | 3 | +450 |
| Modified | 12 | +234 / -156 |
Pushed to: origin/main
| Strategy | Use Case |
|---|---|
| Merge | Preserve commit history (default) |
| Rebase | Linear history, rewrites commits |
| Reset | Match upstream exactly (destructive) |
| Option | Description |
|---|---|
--rebase |
Rebase instead of merge |
--merge |
Merge upstream (default) |
--all |
Sync all tracking branches |
--dry-run |
Preview without changes |
--force |
Force push after sync |
- Git
- GitHub CLI (
gh) for fork detection - Claude Code with Opus 4.5 model access
cd <clone-path>/command-sync-fork && git pull