gg push

Push commits to remote repository with safety checks.

Usage

bash
gg push              # Standard push with confirmation
gg push --dry-run    # Preview what will be pushed
gg push --force      # Force push (careful!)

# Shorthand
gg p

Options

OptionDescription
-f, --forceForce push (use with caution)
--dry-runShow what would be pushed
-y, --yesSkip confirmation prompts

Safety Features

GitGuru includes several safety features when pushing:

  • Shows commits to be pushed - Review what will be sent to remote
  • Confirmation before push - Prevents accidental pushes
  • Warning for force push - Extra confirmation for dangerous operations
  • Dry-run mode - Preview without executing
bash
$ gg push

šŸ“¤ Push Preview
────────────────────────────────────────────────────────────

Branch: feature/auth → origin/feature/auth

Commits to push:
  abc1234 feat: add login functionality
  def5678 feat: add logout endpoint
  ghi9012 test: add auth tests

Total: 3 commits

Proceed with push? (Y/n)

Examples

Standard Push

bash
# Push with confirmation
gg push

# Skip confirmation
gg push -y

Preview Push

bash
# See what would be pushed without actually pushing
gg push --dry-run
Always Preview First
Use gg push --dry-run before pushing to review what commits will be sent. This is especially important after rebasing or amending commits.

Force Push

bash
# Force push (rewrites remote history)
gg push --force
Force Push Warning
Force pushing rewrites remote history and can cause problems for other team members. Only use on personal branches that no one else is working on. Never force push to main or shared branches.

When to Use Force Push

Force push is appropriate in these scenarios:

  • After rebasing your personal feature branch
  • After amending a commit that's already been pushed
  • After squashing commits on your own branch
  • Cleaning up history on a branch only you are using
bash
# After rebasing onto main
gg ask "rebase my branch onto main"
gg push --force

# After amending a commit
gg commit --amend
gg push --force

Pushing a New Branch

When pushing a new branch for the first time:

bash
# GitGuru handles upstream automatically
gg push

# Or explicitly set upstream
gg ask "push and set upstream for current branch"

Troubleshooting

Push Rejected

If your push is rejected because remote has newer commits:

bash
# Pull first, then push
gg pull
gg push

# Or pull with rebase for cleaner history
gg pull --rebase
gg push

No Upstream Branch

bash
# Set upstream and push
gg ask "push and set upstream to origin/my-branch"