gt sync¶
Sync with remote and restack all branches.
Usage¶
Options¶
| Option | Description |
|---|---|
--dry-run |
Show what would happen without making changes |
--watch |
Watch for changes and sync automatically |
--interval <secs> |
Watch interval in seconds (default: 60) |
Examples¶
Basic Sync¶
Preview Changes¶
Auto-Sync Mode¶
Watch for merged PRs and automatically restack:
With custom interval:
Behavior¶
- Fetches from remote
- Updates trunk branch
- Identifies merged branches
- Rebases remaining branches onto their updated parents
- Reports any conflicts
What Gets Synced¶
- Trunk branch is updated from remote
- Merged branches are detected and cleaned up
- Child branches are rebased onto updated parents
Handling Conflicts¶
If conflicts occur during rebase:
# Resolve conflicts in your editor
git add <resolved-files>
# Continue the sync
gt continue
# Or abort
gt abort
Watch Mode¶
Watch mode (--watch) continuously monitors for changes:
- Polls the remote at the specified interval
- Automatically syncs when changes are detected
- Useful when waiting for PR reviews
Press Ctrl+C to stop watching.
Related Commands¶
gt restack- Restack without fetchinggt submit- Push and create PRsgt land- Merge PRs