chore: 重构 OpenCode 命令和技能文档体系
- 新增:统一的 git 命令文档(add/commit/push/pull 等) - 新增:整合的 Gitea 技能文档(API、运行器、工作流等) - 新增:工作流模板(Android、Go、Node.js 等) - 移除:已弃用的旧命令脚本和发布脚本 - 改进:.gitignore 添加敏感文件保护规则 - 改进:AGENTS.md 完善了开发规范和示例 此次重组统一了命令和技能的文档结构,便于后续维护和扩展。
This commit is contained in:
190
command/git-push.md
Normal file
190
command/git-push.md
Normal file
@@ -0,0 +1,190 @@
|
||||
---
|
||||
description: Commit staged files, create version tag, and push to remote repository
|
||||
---
|
||||
|
||||
# git-push
|
||||
|
||||
Complete workflow: auto-generate commit message, create version tag, and push everything to remote repository.
|
||||
|
||||
## What It Does
|
||||
|
||||
This is the **all-in-one command** that:
|
||||
1. ✓ Analyzes and commits staged changes (like `/git-commit`)
|
||||
2. ✓ Creates version tag if needed
|
||||
3. ✓ Pushes commit to remote repository
|
||||
4. ✓ Pushes tag to remote repository
|
||||
|
||||
## Quick Start
|
||||
|
||||
Use this command when you want to commit AND push in one step.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
**Staging area must have files:**
|
||||
```bash
|
||||
git add <files>
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
User can optionally input:
|
||||
- **"skip tag"** or **"skip"**: Skip tag creation, only commit and push
|
||||
|
||||
## Workflow
|
||||
|
||||
This command combines `/git-commit` + push operations:
|
||||
|
||||
1. ✓ Check staging area
|
||||
2. ✓ Analyze changes and repository type
|
||||
3. ✓ Detect project type and version
|
||||
4. ✓ Generate commit message
|
||||
5. ✓ Update version number if needed
|
||||
6. ✓ Commit with generated message
|
||||
7. ✓ Create version tag
|
||||
8. ✓ Push commit to remote
|
||||
9. ✓ Push tag to remote
|
||||
|
||||
## Steps
|
||||
|
||||
### 1-8. Commit and Tag
|
||||
|
||||
Execute the same steps as `/git-commit`:
|
||||
- Check staging area (must not be empty)
|
||||
- Collect information (status, diff, logs, tags, AGENTS.md)
|
||||
- Detect repository type (polyrepo/monorepo)
|
||||
- Detect project type and version file
|
||||
- Generate commit message (Conventional Commits, Chinese/English)
|
||||
- Update version number if needed
|
||||
- Commit changes
|
||||
- Create tag if needed
|
||||
|
||||
Refer to `/git-commit` for detailed steps or see `skill/git/SKILL.md`.
|
||||
|
||||
### 9. Push Commit to Remote
|
||||
|
||||
```bash
|
||||
# Push current branch to origin
|
||||
git push origin $(git branch --show-current)
|
||||
```
|
||||
|
||||
### 10. Push Tag to Remote
|
||||
|
||||
**Only if tag was created:**
|
||||
|
||||
**Polyrepo:**
|
||||
```bash
|
||||
git push origin <version>
|
||||
# Example: git push origin 1.2.0
|
||||
```
|
||||
|
||||
**Monorepo:**
|
||||
```bash
|
||||
git push origin <subproject>-<version>
|
||||
# Example: git push origin ios-1.2.0
|
||||
```
|
||||
|
||||
### 11. Display Result
|
||||
|
||||
Show summary in Chinese:
|
||||
```
|
||||
✓ 提交并推送成功
|
||||
|
||||
分支:main
|
||||
提交信息:feat(android): 添加用户认证
|
||||
版本标签:android-1.3.0
|
||||
|
||||
已推送到远程仓库:origin
|
||||
- 提交:a1b2c3d
|
||||
- 标签:android-1.3.0
|
||||
```
|
||||
|
||||
## Comparison with Other Commands
|
||||
|
||||
| Command | Commit | Tag | Push Commit | Push Tag |
|
||||
|---------|--------|-----|-------------|----------|
|
||||
| `/git-commit` | ✓ | ✓ | ✗ | ✗ |
|
||||
| `/git-push` | ✓ | ✓ | ✓ | ✓ |
|
||||
| `/git-push-tags` | ✗ | ✗ | ✗ | ✓ (all tags) |
|
||||
|
||||
## Use Cases
|
||||
|
||||
- **Quick workflow**: Commit and push in one command
|
||||
- **Release preparation**: Create version tag and push for CI/CD
|
||||
- **Daily development**: Commit and sync with remote immediately
|
||||
|
||||
## When to Use Which Command
|
||||
|
||||
**Use `/git-commit`** (local only):
|
||||
- You want to review before pushing
|
||||
- Working on feature branch not ready to share
|
||||
- Creating multiple commits before one push
|
||||
|
||||
**Use `/git-push`** (commit + push):
|
||||
- Ready to share changes immediately
|
||||
- Main branch development with CI/CD
|
||||
- Quick fixes that should be synced now
|
||||
|
||||
**Use `/git-push-tags`** (tags only):
|
||||
- Already committed but forgot to push tags
|
||||
- Want to push multiple accumulated tags at once
|
||||
- Tag-only sync without new commits
|
||||
|
||||
## Error Handling
|
||||
|
||||
### If Staging Area is Empty
|
||||
|
||||
```
|
||||
暂存区为空,请先使用 `git add` 添加文件。
|
||||
```
|
||||
**Action:** Terminate, user must stage files first.
|
||||
|
||||
### If Push Fails
|
||||
|
||||
Common reasons:
|
||||
- Remote branch protection
|
||||
- Need to pull first (diverged history)
|
||||
- No permission to push
|
||||
|
||||
**Action:** Display error in Chinese, suggest solutions:
|
||||
```
|
||||
✗ 推送失败
|
||||
|
||||
原因:远程分支有更新,需要先拉取
|
||||
|
||||
建议操作:
|
||||
1. git pull --rebase origin main
|
||||
2. 解决冲突(如有)
|
||||
3. 重新运行 /git-push
|
||||
```
|
||||
|
||||
### If Remote Rejects Tag
|
||||
|
||||
If tag already exists on remote:
|
||||
```
|
||||
✗ 标签推送失败
|
||||
|
||||
原因:远程仓库已存在标签 1.2.0
|
||||
|
||||
建议操作:
|
||||
1. 删除本地标签:git tag -d 1.2.0
|
||||
2. 更新版本号后重新提交
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- **Main branch**: Default push target is `main` (not `master`)
|
||||
- **Conventional Commits**: Auto-generated messages follow standard format
|
||||
- **Semantic Versioning**: Automatic version bumping based on change type
|
||||
- **Polyrepo/Monorepo**: Automatically detects and uses correct tag format
|
||||
- **Platform-specific**: Commit messages in Chinese (macOS/Linux) or English (Windows)
|
||||
|
||||
## Related Commands
|
||||
|
||||
- `/git-status` - Check changes before committing
|
||||
- `/git-commit` - Commit locally without pushing
|
||||
- `/git-push-tags` - Push only tags (no commits)
|
||||
|
||||
## Reference
|
||||
|
||||
Complete git workflow guide: `skill/git/SKILL.md`
|
||||
Quick command reference: `skill/git/quick-reference.md`
|
||||
Reference in New Issue
Block a user