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 operations

Options

OptionDescription
-r, --rebaseUse rebase instead of merge
-m, --mergeUse merge (default)
-f, --forceForce push if needed (careful!)
--dry-runShow what would happen
-y, --yesSkip 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 -y

Sync with Rebase

bash
# Rebase local commits on top of remote changes
gg sync --rebase

# Useful for maintaining linear history on feature branches

Preview Sync

bash
# See what would happen without doing it
gg sync --dry-run
Dry 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 --continue

Common Use Cases

Morning Sync

bash
# Start of day - get latest changes
gg sync

Before Creating PR

bash
# Ensure branch is up to date before PR
gg sync --rebase

End of Day

bash
# Share your work
gg commit -m "WIP: feature progress"
gg sync