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 pOptions
| Option | Description |
|---|---|
-f, --force | Force push (use with caution) |
--dry-run | Show what would be pushed |
-y, --yes | Skip 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 -yPreview Push
bash
# See what would be pushed without actually pushing
gg push --dry-runAlways 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 --forceForce 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 --forcePushing 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 pushNo Upstream Branch
bash
# Set upstream and push
gg ask "push and set upstream to origin/my-branch"