Skip to main content

Module sync

Module sync 

Source
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:

SituationWhat gw sync does
on the home branchfast-forward pull from origin/main
plain branch (base is main)git rebase origin/main, force-push if published
stacked, base PR still openrebase onto origin/<base>, force-push
stacked, base PR mergedrebase --onto origin/main <old base>, move the PR
base to main, force-push (restack)
stacked before a PR exists, base mergedrebase --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...
  ✓ Synced

Functions§

run
Execute the sync command