Files
opencode/skill/git/push-workflow.md

108 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Git Push Workflow
提交暂存文件,创建版本标签并推送到远程仓库的完整工作流。
## 概述
此工作流是 **All-in-One** 命令,组合了:
- `/git-commit` 的所有功能
- 推送提交到远程
- 推送标签到远程
## 执行步骤
### 步骤 1-9: 与 Commit Workflow 相同
参考 [Commit Workflow](./commit-workflow.md)
1. 检查暂存区(不能为空)
2. 收集变更信息和仓库状态
3. 检测仓库类型polyrepo/monorepo
4. 检测项目类型和版本
5. 生成提交信息Conventional Commits中文
6. 确定新版本号
7. 更新版本文件并添加到暂存区
8. 执行提交
9. 创建版本标签
### 步骤 10: 推送提交到远程
```bash
git push origin $(git branch --show-current)
```
### 步骤 11: 推送标签到远程
仅在创建了标签时执行:
**Polyrepo**
```bash
git push origin <version>
```
**Monorepo**
```bash
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>` |
## 相关文档
- [Git Workflow Best Practices](./SKILL.md)
- [Commit Workflow](./commit-workflow.md)