skills/git-workflows/skills/push/SKILL.md
Push commits to remote with upstream handling
npx skillsauth add dtsong/my-claude-setup Git PushInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
--force-with-lease requires explicit user request-u, --force-with-lease accepted. Reject --force without --with-lease, arbitrary strings, and shell metacharacters..., or null bytes.Push local commits to remote repository with smart upstream handling.
/git-push # Push to tracking branch
/git-push -u # Push and set upstream (for new branches)
/git-push --force-with-lease # Safe force push for rebased branches
# Get current branch
BRANCH=$(git branch --show-current)
# Prevent pushing to protected branches without confirmation
if [[ "$BRANCH" == "main" || "$BRANCH" == "master" ]]; then
echo "Warning: You're about to push directly to $BRANCH"
# User should confirm
fi
# Check if there are commits to push
if git diff --quiet @{u}..HEAD 2>/dev/null; then
echo "No commits to push. Branch is up to date with remote."
exit 0
fi
# Check if upstream is configured
if ! git rev-parse --abbrev-ref --symbolic-full-name @{u} >/dev/null 2>&1; then
echo "No upstream configured. Setting upstream to origin/$BRANCH"
NEEDS_UPSTREAM=true
fi
# Fetch to ensure we're comparing with latest
git fetch --quiet
# Check if we're behind
BEHIND=$(git rev-list --count HEAD..@{u} 2>/dev/null || echo "0")
if [ "$BEHIND" -gt 0 ]; then
echo "Remote has $BEHIND commits not in local."
echo "Pull first with: /git-pull"
exit 1
fi
# Standard push with upstream
if [ "$NEEDS_UPSTREAM" = true ]; then
git push -u origin "$BRANCH"
else
git push
fi
# For force push (after rebase)
# git push --force-with-lease
Show what was pushed and provide next steps.
Pushed to origin/feat/dark-mode
Commits pushed:
abc1234 Add theme toggle component
def5678 Wire up theme context
ghi9012 Add dark mode styles
Branch is now synced with remote.
Next steps:
/gh-pr-status # Check if PR exists
/commit-push-pr # Create a PR if needed
Branch feat/new-feature pushed to origin for the first time.
Upstream set: origin/feat/new-feature
Next steps:
/commit-push-pr # Create a pull request
/gh-pr-status # Check PR status
Push rejected! Remote has changes not in local.
Remote is 2 commits ahead:
xyz7890 Someone else's commit
uvw1234 Another commit
Options:
/git-pull --rebase # Rebase your changes on top
/git-pull # Merge remote changes
You're about to force push to feat/shared-branch
This will overwrite remote history!
Only do this if:
- You just rebased and need to update the PR
- No one else is working on this branch
- You understand the implications
To proceed:
git push --force-with-lease
To cancel:
This skill will not force push automatically.
--force for safety| Scenario | Command |
|----------|---------|
| Normal push | /git-push |
| New branch first push | /git-push -u |
| After rebasing | /git-push --force-with-lease |
| To different remote | Use git push <remote> <branch> |
/commit to create commits before pushing/git-sync to check remote status first/commit-push-pr for full commit-push-PR workflow/gh-pr-status after pushing to check PR statusdevelopment
Use when planning implementation steps, deciding commit format, or structuring development approach. Provides brainstorm-plan-implement flow with conventional commits. Triggers on 'how should I approach this', 'commit format'.
development
Security audit checklist for web applications. Use when reviewing, auditing, or hardening a web app's security posture. Covers rate limiting, auth headers, IP blocking, CORS, security middleware, input validation, file upload limits, ORM usage, and password hashing. Triggers on requests like "review security", "harden this app", "security audit", "check for vulnerabilities", or when building/reviewing API endpoints.
development
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
development
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.