Git Flow Guide
Git Flow Guide
本專案採用 Trunk-Based Development,以 main 為唯一長期分支,搭配 Vercel 自動部署。
分支策略
| 分支 | 用途 | 生命週期 |
|------|------|----------|
| main | 正式環境,Vercel 自動部署 | 永久 |
| feature/* | 新功能開發 | 合併後刪除 |
| fix/* | Bug 修正 | 合併後刪除 |
原則:直接推
main適用於小幅文件更新(如新增 content/ 文件)。功能性修改建議開分支。
遠端倉庫
- 平台:GitLab(
gitlab.com:moneymaster-develop/playbook) - 部署:Vercel 連接 GitLab,push to
main自動觸發 Production 部署
Commit 規範
採用 Conventional Commits 格式:
<type>: <簡短描述>
Type 對照
| Type | 使用時機 | 範例 |
|------|----------|------|
| feat | 新功能或重大改動 | feat: ISR instant content update + editor improvements |
| fix | Bug 修正 | fix: slash command arrow key navigation |
| docs | 文件新增或更新 | docs: update Git Flow Guide |
| style | 樣式調整(不影響邏輯) | style: adjust task list checkbox alignment |
| refactor | 重構(不改變行為) | refactor: extract theme utils |
| test | 測試相關 | test: add editor e2e tests |
| chore | 建置、設定、依賴更新 | chore: upgrade next to 16.2 |
日常工作流程
新增文件(簡單情境)
直接在 main 操作:
# 建立新文件
vim content/tech-sharing/my-topic.md
# 提交並推送
git add content/tech-sharing/my-topic.md
git commit -m "docs: create my-topic"
git push origin main
# → Vercel 自動部署
功能開發(需要分支)
# 開新分支
git checkout -b feature/editor-toolbar
# 開發、測試
npm test
npm run build
# 提交
git add -A
git commit -m "feat: add editor toolbar"
# 推送並在 GitLab 開 Merge Request
git push origin feature/editor-toolbar
# MR 合併後清理
git checkout main
git pull
git branch -d feature/editor-toolbar
部署流程
push to main → Vercel 自動建置 → Production 部署
↓
ISR 增量更新(文件內容變更 60 秒內生效)
- Preview 部署:每個推到非 main 分支的 push 都會產生 Preview URL
- Production 部署:只有
main觸發正式部署 - ISR:文件頁面使用 Incremental Static Regeneration,內容更新後自動 revalidate
注意事項
- 提交前確認
npm test和npm run build都通過 .env.local已在.gitignore,不要提交敏感資訊content/資料夾結構即側邊選單結構,新增資料夾請用 kebab-case 命名