Skip to main content
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

Flags

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:
This atomically updates all intermediate branch refs. It is only used when the stack is a linear chain (no siblings).

--onto fallback (Git < 2.38 or non-linear stacks)

Falls back to iterating through branches one at a time:
This uses the stored parent_head values to compute the correct --onto base for each branch.

Examples

Safety Guards

gx sync blocks if the working tree is dirty (uncommitted changes). You must commit or stash your changes before syncing:

Conflict Handling

If a rebase conflict occurs, gx stops and shows:
After resolving conflicts and completing the rebase, you can re-run gx sync with the remaining branches to continue.
gx sync pushes with --force-with-lease to the remote. This is safe for branches you own but can overwrite remote changes made by others. Coordinate with collaborators before syncing shared branches.
  • Sync blocks if the working tree is dirty (uncommitted changes)
  • 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_head values are batch-updated for all synced branches
  • The --onto fallback captures pre-rebase SHAs before starting, so each branch gets the correct old base even as branches are rebased in sequence
  • If --update-refs detects siblings in the stack, it falls back to --onto iteration with a message