gx sync rebases an entire stack of branches in the correct order, then pushes each one with --force-with-lease. It automatically detects the best rebase strategy based on your git version.
Usage
Arguments
| Argument | Description |
|---|---|
branches... | Explicit list of branches to sync in order |
Flags
| Flag | Description |
|---|---|
--stack | Auto-detect and sync the current branch’s full stack (root to leaf) |
--dry-run | Show what would happen without making changes |
Rebase Strategies
gx chooses the best strategy based on your git version:--update-refs (Git 2.38+)
The preferred strategy. Rebases the entire chain in a single operation by checking out the tip branch and running:
--onto fallback (Git < 2.38 or non-linear stacks)
Falls back to iterating through branches one at a time:
parent_head values to compute the correct --onto base for each branch.
Examples
Conflict Handling
If a rebase conflict occurs, gx stops and shows:gx sync with the remaining branches to continue.
Details
Details
- The chain auto-detection walks up from the current branch to the root, then down through all descendants
- At least 2 branches are needed (root + 1 child) for sync to run
- If the stack has 5+ branches, gx asks for confirmation before proceeding
- After a successful sync,
parent_headvalues are updated for all synced branches - The
--ontofallback captures pre-rebase SHAs before starting, so each branch gets the correct old base even as branches are rebased in sequence - If
--update-refsdetects siblings in the stack, it falls back to--ontoiteration with a message