2.0 KiB
2.0 KiB
Git Push Workflow
提交暂存文件,创建版本标签并推送到远程仓库的完整工作流。
概述
此工作流是 All-in-One 命令,组合了:
/git-commit的所有功能- 推送提交到远程
- 推送标签到远程
执行步骤
步骤 1-9: 与 Commit Workflow 相同
参考 Commit Workflow:
- 检查暂存区(不能为空)
- 收集变更信息和仓库状态
- 检测仓库类型(polyrepo/monorepo)
- 检测项目类型和版本
- 生成提交信息(Conventional Commits,中文)
- 确定新版本号
- 更新版本文件并添加到暂存区
- 执行提交
- 创建版本标签
步骤 10: 推送提交到远程
git push origin $(git branch --show-current)
步骤 11: 推送标签到远程
仅在创建了标签时执行:
Polyrepo:
git push origin <version>
Monorepo:
git push origin <subproject>-<version>
选项
skip tag/skip:跳过标签创建
输出格式
✓ 提交并推送成功
分支:[branch]
提交信息:[commit message]
版本标签:[tag](如果创建了)
已推送到远程仓库:origin
- 提交:[commit hash]
- 标签:[tag]
错误处理
暂存区为空
暂存区为空,请先使用 `git add` 添加文件。
推送失败
❌ 推送失败:[error message]
可能的解决方案:
1. 先拉取远程变更:git pull origin <branch>
2. 检查网络连接
3. 检查远程仓库权限
标签已存在
❌ 标签推送失败:tag already exists
解决方案:
1. 删除本地标签:git tag -d <tag>
2. 更新版本号后重新提交
使用场景
| 场景 | 推荐命令 |
|---|---|
| 本地提交,稍后审查 | /git-commit |
| 提交并立即推送 | /git-push |
| 仅推送已有提交 | git push origin <branch> |
| 仅推送标签 | git push origin <tag> |