geo/docs/03-开发指南/git-workflow.md

131 lines
1.9 KiB
Markdown
Raw Permalink 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工作流
## 分支策略
### 主分支
| 分支 | 说明 | 保护 |
|------|------|------|
| main | 生产环境代码 | 必须PR |
| develop | 开发分支 | 必须PR |
### 功能分支
从develop分支创建
```bash
git checkout develop
git pull origin develop
git checkout -b feature/功能名称
```
### 命名规范
| 类型 | 格式 | 示例 |
|------|------|------|
| 功能 | feature/功能名 | feature/user-auth |
| 修复 | fix/问题描述 | fix/login-error |
| 热修复 | hotfix/问题描述 | hotfix/critical-bug |
| 重构 | refactor/描述 | refactor/api-layer |
## 提交规范
遵循Conventional Commits
```
<type>(<scope>): <subject>
<body>
<footer>
```
### 类型
| 类型 | 说明 |
|------|------|
| feat | 新功能 |
| fix | 修复bug |
| docs | 文档 |
| style | 格式 |
| refactor | 重构 |
| test | 测试 |
| chore | 构建/工具 |
### 示例
```
feat(auth): 添加邮箱验证功能
实现用户邮箱验证流程
- 发送验证邮件
- 验证链接有效性
- 处理验证结果
Closes #123
```
## Pull Request流程
### 1. 创建PR
```bash
git push origin feature/功能名称
# 在GitHub/Gitea上创建PR
```
### 2. PR内容模板
```markdown
## 描述
简要说明本次更改
## 更改类型
- [ ] 新功能
- [ ] 修复bug
- [ ] 重构
- [ ] 文档更新
## 测试
- [ ] 单元测试通过
- [ ] 集成测试通过
- [ ] E2E测试通过
## 截图如有UI更改
```
### 3. 代码审查
- 至少1人review
- 所有review意见必须处理
- CI必须通过
### 4. 合并
使用Squash Merge保持提交历史整洁
## 常用命令
```bash
# 拉取最新代码
git pull origin develop
# 创建功能分支
git checkout -b feature/功能名
# 提交代码
git add .
git commit -m "feat(scope): description"
# 推送代码
git push origin feature/功能名
# 更新分支
git fetch origin
git rebase origin/develop
# 查看状态
git status
git log --oneline -10
```