Git 工作流最佳实践
分支策略
Git Flow
- main:生产分支
- develop:开发分支
- feature/*:功能分支
- release/*:发布分支
- hotfix/*:热修复分支
GitHub Flow
更简单的工作流:
- 从 main 创建功能分支
- 提交更改
- 创建 Pull Request
- 代码审查
- 合并到 main
提交规范
<type>(<scope>): <subject>
<body>
<footer>
Type 类型
feat: 新功能fix: 修复docs: 文档style: 格式refactor: 重构test: 测试
常用命令
# 创建并切换分支
git checkout -b feature/new-feature
# 查看分支
git branch -a
# 合并分支
git merge feature/new-feature