git town sync: Sync Feature Branches With Trunk
git town sync updates the current branch and its ancestors with the latest trunk and pushes the result.
git-town automates a trunk-based branching workflow. git town sync brings a feature branch (and its parent chain) up to date with the main branch and pushes, in one command.
What it does
git town sync pulls the latest trunk (the configured main branch), merges or rebases it into the current branch chain according to your sync strategy, and pushes. --all syncs every local branch; --stack syncs the current branch and its ancestors.
Common usage
# sync the current branch chain with trunk
git town sync
# sync every local branch
git town sync --all
# non-interactive setup of the main branch (needed once)
git config git-town.main-branch mainOptions
| Flag / Config | What it does |
|---|---|
| --all | Sync all local branches, not just the current chain |
| --stack | Sync the current branch and its ancestors |
| --no-push | Sync locally but do not push |
| --detached | Do not pull updates from trunk (local sync only) |
| git-town.main-branch | Config: which branch is trunk |
| git-town.sync-feature-strategy | Config: merge or rebase |
In CI
git-town needs its main branch configured (git config git-town.main-branch main) and a full checkout, not a shallow one, so it can find the trunk history. Set the sync strategy explicitly and use --no-push if the job should not write back to the remote.
Common errors in CI
"this is not a git repository" or "cannot sync: this is not a Git repository" means the command ran outside a checkout. "the required Git Town configuration is missing" or "please provide the main branch" means git-town.main-branch is unset. On a shallow clone git town sync can fail to find trunk; fetch with --unshallow first.