git-push
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit Push Skill
Git Push Skill
<scripts>
<scripts>
Available scripts
可用脚本
| Script | Purpose |
|---|---|
| Discover repos, check for unpushed commits, and push safely |
- Push unpushed commits to the remote for all discovered repositories.
- Do nothing if there are no commits to push.
- Block unsafe operations (force push to main/master, detached HEAD).
<trigger_conditions>
| User intent | Activate |
|---|---|
| "push" | yes |
| "git push" | yes |
| "/git-push" | yes |
| "push my changes" | yes |
| "push commits to remote" | yes |
| "sync to remote" | yes |
| requests that only ask for commit/rebase/reset | no |
| "push back on this idea" (non-git context) | no |
</trigger_conditions>
<argument_validation>
If ARGUMENT is missing:
- Push all unpushed commits in all discovered repositories.
If ARGUMENT is :
--force- Use for push. Protected branches (main/master) are still blocked.
--force-with-lease
</argument_validation>
<scope_assumptions>
- Start from the current working directory. If it is not a git repository, inspect descendant directories for git repositories.
- Push only. Do not commit, amend, rebase, or rewrite history.
- No confirmation needed — if there are commits to push, push them immediately.
- Use Bash commands only.
</scope_assumptions>
<required>
| Category | Rule |
|---|---|
| Safety | Never force push to main or master. |
| Safety | Never push from detached HEAD. |
| Safety | Use |
| Upstream | If no upstream is set, push with |
| Idempotent | If already up to date, report and exit cleanly. |
| Multi-repo | Handle descendant repositories independently. |
| Category | Avoid |
|---|---|
| Force push | |
| History rewrite | amend, rebase, reset, or other history-editing commands |
| Commit | Do not create commits — that is the git-commit skill's job |
| Raw force | |
| Script | 用途 |
|---|---|
| 识别仓库,检查未推送的提交并安全推送 |
- 将所有识别到的仓库中的未推送提交推送到远程仓库。
- 如果没有需要推送的提交则不执行任何操作。
- 阻止不安全操作(强制推送到main/master分支、分离HEAD状态)。
<trigger_conditions>
| 用户意图 | 是否触发 |
|---|---|
| "push" | 是 |
| "git push" | 是 |
| "/git-push" | 是 |
| "push my changes" | 是 |
| "push commits to remote" | 是 |
| "sync to remote" | 是 |
| 仅请求提交/变基/重置的需求 | 否 |
| "push back on this idea"(非Git场景) | 否 |
</trigger_conditions>
<argument_validation>
如果缺少参数:
- 推送所有识别到的仓库中所有未推送的提交。
如果参数为:
--force- 使用进行推送。受保护分支(main/master)仍会被阻止。
--force-with-lease
</argument_validation>
<scope_assumptions>
- 从当前工作目录开始。如果当前目录不是Git仓库,则检查子目录中的Git仓库。
- 仅执行推送操作。不执行提交、修改提交、变基或重写历史的操作。
- 无需确认——如果有需要推送的提交,立即推送。
- 仅使用Bash命令。
</scope_assumptions>
<required>
| 类别 | 规则 |
|---|---|
| 安全性 | 绝不强制推送到main或master分支。 |
| 安全性 | 绝不从分离HEAD状态推送。 |
| 安全性 | 强制推送时使用 |
| 上游设置 | 如果未设置上游分支,使用 |
| 幂等性 | 如果已经与上游同步,报告状态并正常退出。 |
| 多仓库处理 | 独立处理子目录中的仓库。 |
| 类别 | 禁止操作 |
|---|---|
| 强制推送 | 对main或master分支使用 |
| 历史重写 | 修改提交、变基、重置或其他编辑历史的命令 |
| 提交操作 | 不创建提交——这是git-commit技能的职责 |
| 直接强制推送 | 使用 |
Run the script
运行脚本
bash
scripts/git-push.shOr with force:
bash
scripts/git-push.sh --forceThe script handles everything:
- Discovers repositories (current directory or descendants).
- For each repository, checks the branch and upstream status.
- Skips repositories with no unpushed commits, detached HEAD, or protected branch conflicts.
- Pushes repositories that have commits ahead of upstream.
- Reports a summary of pushed, skipped, and failed repositories.
bash
scripts/git-push.sh或带强制参数:
bash
scripts/git-push.sh --force脚本会处理所有操作:
- 识别仓库(当前目录或子目录)。
- 对每个仓库,检查分支和上游状态。
- 跳过没有未推送提交、处于分离HEAD状态或存在受保护分支冲突的仓库。
- 推送那些提交领先于上游的仓库。
- 报告已推送、已跳过和推送失败的仓库汇总信息。
Simple push
简单推送
text
/git-pushResult: discovers repos, pushes any that have unpushed commits.
text
/git-push结果:识别仓库,推送所有存在未推送提交的仓库。
Force push (feature branch)
强制推送(功能分支)
text
/git-push --forceResult: pushes with . Blocked on main/master.
--force-with-leasetext
/git-push --force结果:使用推送。在main/master分支上会被阻止。
--force-with-leaseNothing to push
无内容可推送
text
/git-pushResult: reports "Already up to date" and exits cleanly.
text
/git-push结果:报告“Already up to date”并正常退出。
Multi-repo push
多仓库推送
text
/git-pushResult: discovers descendant repos, pushes each independently, reports summary.
</examples>
<validation>
- Confirm the script was executed, not manual git commands.
- Confirm force push was not used on main/master.
- Confirm detached HEAD was skipped.
- Confirm the summary output was reported to the user.
text
/git-push结果:识别子目录中的仓库,独立推送每个仓库,报告汇总信息。
</examples>
<validation>
- 确认执行的是脚本而非手动Git命令。
- 确认未对main/master分支使用强制推送。
- 确认已跳过分离HEAD状态的仓库。
- 确认已向用户报告汇总输出信息。