用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill git-push命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | git-push |
| description | Push commits to remote with upstream handling Use when this capability is needed. |
| metadata | {"author":"dtsong"} |
--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 statusConverted and distributed by TomeVault — claim your Tome and manage your conversions.