Expand description
gw sync command - Bring the current branch up to date with its base.
“Base” is whatever this branch is meant to sit on, and sync always moves
the branch onto the latest version of it:
| Situation | What gw sync does |
|---|---|
| on the home branch | fast-forward pull from origin/main |
plain branch (base is main) | git rebase origin/main, force-push if published |
| stacked, base PR still open | rebase onto origin/<base>, force-push |
| stacked, base PR merged | rebase --onto origin/main <old base>, move the PR |
base to main, force-push (restack) | |
| stacked before a PR exists, base merged | rebase --onto origin/main <recorded base tip> |
Rebasing a stacked branch always uses --onto with the recorded base tip
(gw new --stack stores it) as the boundary, so only this branch’s own
commits are replayed — never the base’s, which after a squash merge would be
doubled and conflict-prone. A plain git rebase is used only when nothing
better is known (base is main, or a stack created without gw new --stack).
§Example
$ gw status
Branch: feature/child
PR: #42 (open)
Base: feature/base (merged ✓)
Next: gw sync
$ gw sync
Rebasing commits after <base tip> onto origin/main...
Updating PR base to main...
Force pushing...
✓ SyncedFunctions§
- run
- Execute the
synccommand