gg sync
Complete synchronization: fetch ā pull ā push in one command.
Usage
bash
gg sync # Full sync with merge
gg sync --rebase # Full sync with rebase
gg sync --dry-run # Preview sync operationsOptions
| Option | Description |
|---|---|
-r, --rebase | Use rebase instead of merge |
-m, --merge | Use merge (default) |
-f, --force | Force push if needed (careful!) |
--dry-run | Show what would happen |
-y, --yes | Skip confirmation prompts |
Sync Workflow
The sync command performs three operations in sequence:
1
Fetch
Downloads new data from remote without modifying your working directory.
2
Pull
Integrates remote changes into your current branch (merge or rebase).
3
Push
Sends your local commits to the remote repository.
One Command Workflow
Use
gg sync at the start of your work session to ensure you're up to date, and at the end to share your changes. It replaces the need to remember the fetch-pull-push sequence.Output
bash
$ gg sync
š Starting sync...
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Step 1/3: Fetching
ā Fetched 5 commits from origin/main
Step 2/3: Pulling
ā Merged 5 commits into main
ā No conflicts
Step 3/3: Pushing
ā Pushed 3 commits to origin/main
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā
Sync complete!
Summary:
Received: 5 commits
Sent: 3 commits
Branch: main ā origin/main (in sync)Examples
Basic Sync
bash
# Standard sync with merge
gg sync
# Skip confirmations
gg sync -ySync with Rebase
bash
# Rebase local commits on top of remote changes
gg sync --rebase
# Useful for maintaining linear history on feature branchesPreview Sync
bash
# See what would happen without doing it
gg sync --dry-runDry Run Output
The dry-run mode shows:
- How many commits will be fetched
- How many commits will be merged/rebased
- How many commits will be pushed
- Potential conflicts
Force Sync After Rebase
bash
# After rebasing your branch locally
gg sync --force
# Warning: Only use on personal branches!Force Push Warning
The
--force option will force push if your local history diverges from remote. Only use this on branches that no one else is working on.Handling Conflicts During Sync
If conflicts occur during the pull step:
bash
$ gg sync
š Starting sync...
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Step 1/3: Fetching
ā Fetched 3 commits from origin/main
Step 2/3: Pulling
ā ļø Conflicts detected!
Conflicting files:
src/config.ts
src/utils/helpers.ts
Sync paused. Resolve conflicts and run:
gg sync --continue
Or get AI help:
gg ask "help resolve conflicts"bash
# After resolving conflicts
gg ask "continue sync after resolving conflicts"
# Or manually
git add .
gg sync --continueCommon Use Cases
Morning Sync
bash
# Start of day - get latest changes
gg syncBefore Creating PR
bash
# Ensure branch is up to date before PR
gg sync --rebaseEnd of Day
bash
# Share your work
gg commit -m "WIP: feature progress"
gg sync