push
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePush
推送
Purpose
用途
- Push the current branch to safely.
origin - Keep branch history clean when the remote has moved forward (coordinate with pull as needed).
- 安全地将当前分支推送到远程仓库。
origin - 当远程仓库分支有更新时,保持本地分支历史记录整洁(必要时与pull技能配合)。
Prerequisites
前提条件
- Git remote is configured and reachable.
origin - Credentials for work for this host (HTTPS or SSH).
git push
- Git远程仓库已配置且可访问。
origin - 用于的凭证在当前主机上可用(HTTPS或SSH方式均可)。
git push
When to Use
使用场景
- "pushして", "リモートに出して", "origin に push", or similar—when the user asks to push commits to the remote.
- 当用户提出「pushして」「リモートに出して」「origin に push」或类似需求时——即用户要求将提交推送到远程仓库时使用。
Do Not Use When
禁用场景
- Only syncing or updating the local branch is needed (use the pull skill).
- The user wants a PR opened or updated (use the create-pr-jp skill—out of scope for this skill).
- 仅需要同步或更新本地分支时(请使用pull技能)。
- 用户需要创建或更新PR时(请使用create-pr-jp技能——此操作不在本技能的范围内)。
Related Skills
相关技能
- pull: When push is rejected or the branch is not cleanly synced (non-fast-forward, merge conflicts, branch behind remote).
- create-pr-jp: When the user wants to create or update a GitHub PR (Japanese title/body per repo rules).
- pull:当推送被拒绝或分支未完全同步时(非快进、合并冲突、分支落后于远程仓库)。
- create-pr-jp:当用户需要创建或更新GitHub PR时(需遵循仓库规则设置日文标题/正文)。
Procedure
操作步骤
- Identify the current branch and inspect remote state (,
git status,git remote -vas needed).git fetch - Run local checks before pushing: then
pnpm lint(orpnpm test), unless the repo documents different pre-push checks.pnpm lint && pnpm test - Push to , setting upstream tracking if needed (
origin).git push -u origin HEAD - If push fails or is non-fast-forward:
- For non-fast-forward or sync issues: use the pull skill to merge or rebase per repo rules (or the appropriate base), resolve conflicts, re-run
origin/main, then push again. Usepnpm lint && pnpm testonly when history was rewritten intentionally.--force-with-lease - For auth, permissions, or host policy: do not rewrite the remote or change protocols; show the exact error and stop.
- For non-fast-forward or sync issues: use the pull skill to merge or rebase per repo rules (
- 确定当前分支并检查远程仓库状态(必要时执行、
git status、git remote -v命令)。git fetch - 推送前先执行本地检查:然后
pnpm lint(或合并为pnpm test),除非仓库文档中指定了其他推送前检查流程。pnpm lint && pnpm test - 将分支推送到,必要时设置上游跟踪(
origin)。git push -u origin HEAD - 如果推送失败或出现非快进情况:
- 针对非快进或同步问题:使用pull技能,按照仓库规则合并或变基(基于或相应的基准分支),解决冲突后重新执行
origin/main,然后再次推送。仅当有意重写提交历史时,才可使用pnpm lint && pnpm test参数。--force-with-lease - 针对认证、权限或主机策略问题:请勿重写远程仓库内容或更改协议,直接显示具体错误信息并停止操作。
- 针对非快进或同步问题:使用pull技能,按照仓库规则合并或变基(基于
Output
输出结果
- A successful to
git pushfor the current branch (and upstream set when first pushing the branch).origin
- 当前分支成功推送到远程仓库(首次推送分支时会设置上游跟踪)。
origin
Usage
使用示例
Reference flow (adapt branch names and commands to the repo):
sh
branch=$(git branch --show-current)参考流程(可根据仓库情况调整分支名称和命令):
sh
branch=$(git branch --show-current)Validation gate (lint then test; use repo-specific scripts if documented)
验证环节(先lint再测试;如果仓库有文档说明,请使用仓库特定的脚本)
pnpm lint && pnpm test
pnpm lint && pnpm test
Push (with upstream tracking on first push)
推送(首次推送时设置上游跟踪)
git push -u origin HEAD
git push -u origin HEAD
If the remote moved: resolve via the pull skill, re-run pnpm lint && pnpm test
, then:
pnpm lint && pnpm test如果远程仓库有更新:通过pull技能解决问题,重新执行pnpm lint && pnpm test
,然后执行:
pnpm lint && pnpm testgit push -u origin HEAD
git push -u origin HEAD
Auth/permission failures: show the error and stop—do not force-push to fix.
认证/权限失败:显示错误信息并停止——请勿使用强制推送来修复问题。
Only after intentional history rewrite:
仅当有意重写提交历史后:
git push --force-with-lease origin HEAD
git push --force-with-lease origin HEAD
undefinedundefinedPresent Results to User
向用户展示结果
- Confirm the branch name and that the push to succeeded.
origin - If push failed, report the exact error and what was tried (e.g. pull/rebase)—do not imply a PR was created or updated (that is create-pr-jp’s job).
- 确认分支名称,并告知用户已成功推送到。
origin - 如果推送失败,报告具体错误信息及已尝试的操作(例如拉取/变基)——请勿暗示已创建或更新PR(该操作属于create-pr-jp技能的范畴)。
Notes
注意事项
- Never use . Use
--forceonly as a last resort when history was intentionally rewritten.--force-with-lease - Distinguish sync issues from auth/permission issues: resolve the former with pull; for the latter, surface errors without changing remotes or protocols.
- 永远不要使用参数。仅当有意重写提交历史时,才可作为最后手段使用
--force参数。--force-with-lease - 区分同步问题与认证/权限问题:前者通过pull技能解决;后者直接显示错误信息,请勿修改远程仓库配置或协议。
Troubleshooting
故障排除
| Situation | Action |
|---|---|
| pull skill → merge/rebase per repo rules → |
| Credential / permission denied | Report verbatim; user fixes credentials or repo access—do not bypass with force push |
| Wrong remote or branch | Verify |
| 场景 | 操作 |
|---|---|
| 非快进 / 分支落后于远程仓库 | 使用pull技能 → 按照仓库规则合并/变基 → 执行 |
| 凭证 / 权限被拒绝 | 直接报告错误信息;由用户修复凭证或仓库访问权限——请勿使用强制推送绕过问题 |
| 远程仓库或分支错误 | 推送前先验证 |