Skip to content
Latchkey

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

Terminal
# 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 main

Options

Flag / ConfigWhat it does
--allSync all local branches, not just the current chain
--stackSync the current branch and its ancestors
--no-pushSync locally but do not push
--detachedDo not pull updates from trunk (local sync only)
git-town.main-branchConfig: which branch is trunk
git-town.sync-feature-strategyConfig: 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.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →