sync
Sync the stack by rebasing all branches when their parent branches have moved forward. This is the core command for keeping your stack up-to-date.
Usage
rung syncrung sync --dry-runrung sync --base developrung sync --continuerung sync --abortrung sync --no-pushAliases
rung sy— shorthand forrung sync
Options
| Option | Description |
|---|---|
--dry-run | Show what would be done without making changes |
-b, --base <branch> | Base branch to sync against (auto-detected from GitHub by default) |
--continue | Continue after resolving conflicts |
--abort | Abort and restore from backup |
--no-push | Skip pushing branches to remote after sync |
How It Works
When you run rung sync:
- Backup — Creates backup refs for all branches
- Plan — Determines which branches need rebasing
- Rebase — For each branch (bottom-up):
git rebase --onto <new-parent> <old-parent> <branch> - Report — Shows what was rebased
Example
$ rung sync✓ Synced feat-add-user-model (rebased 3 commits onto main)✓ Synced feat-add-user-api (rebased 2 commits onto feat-add-user-model)✓ Synced feat-add-user-tests (rebased 1 commit onto feat-add-user-api)Dry Run
Preview changes without modifying anything:
$ rung sync --dry-run
Would sync: feat-add-user-model: rebase 3 commits onto main (abc123..def456) feat-add-user-api: rebase 2 commits onto feat-add-user-model feat-add-user-tests: rebase 1 commit onto feat-add-user-apiHandling Conflicts
If a conflict occurs during sync, rung pauses and shows you what to do:
$ rung sync✓ Synced feat-add-user-model✗ Conflict in feat-add-user-api
Conflict in: src/api/users.rs
Resolve the conflict, then run: rung sync --continue
Or abort and restore: rung sync --abortResolving Conflicts
- Open the conflicting files and resolve the conflicts
- Stage the resolved files:
Terminal window git add src/api/users.rs - Continue the sync:
Terminal window rung sync --continue
Aborting
If you want to discard the partial sync and restore your branches:
rung sync --abortThis restores all branches to their pre-sync state using the backup refs.
Using a Different Base
By default, rung syncs against main. To use a different base:
rung sync --base developSync State
During a sync operation, rung writes state to .git/rung/sync_state.json:
{ "started_at": "2024-01-15T10:30:00Z", "backup_id": "1704067200", "current_branch": "feat-add-user-api", "completed": ["feat-add-user-model"], "remaining": ["feat-add-user-tests"]}This allows --continue to resume from where it left off.
JSON Output
$ rung sync --json{ "status": "complete", "branches_synced": [ { "name": "feat-add-user-model", "commits": 3 }, { "name": "feat-add-user-api", "commits": 2 } ], "backup_id": "1704067200"}Or if there’s a conflict:
{ "status": "conflict", "branch": "feat-add-user-api", "files": ["src/api/users.rs"], "completed": ["feat-add-user-model"], "remaining": ["feat-add-user-tests"], "backup_id": "1704067200"}Notes
- Always commit or stash your changes before syncing
- The sync algorithm processes branches bottom-up (from root to tips)
- Backup refs are stored in
.git/rung/backups/for undo capability - If no branches need syncing, rung reports “Already synced”