git-commit-guide

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git Commit Guidelines

Git 提交规范

Commit Message Format

提交信息格式

<type>(<scope>): <subject in Thai or English>

[optional body]
<type>(<scope>): <subject in Thai or English>

[optional body]

Types

提交类型

TypeWhen to use
feat
New feature or page added
fix
Bug fix
refactor
Code restructure without behavior change
style
UI/CSS changes only (no logic change)
chore
Config, deps, tooling (prisma generate, etc.)
docs
Documentation or comment changes
perf
Performance improvement
提交类型适用场景
feat
新增功能或页面
fix
修复Bug
refactor
重构代码(不改变功能)
style
仅UI/CSS变更(无逻辑改动)
chore
配置、依赖、工具相关变更(如prisma generate等)
docs
文档或注释变更
perf
性能优化

Scopes Matched to This Project

项目对应的提交范围

ScopeMaps to
auth
src/lib/auth.ts
,
src/lib/auth-client.ts
,
(auth)/
routes
product
(front)/product/
,
app-product-card.tsx
cart
src/lib/cart-store.ts
, cart components
course
(front)/course/
,
src/services/course-service.ts
contact
(front)/contact/
,
src/app/api/contact/
prisma
prisma/schema.prisma
,
src/lib/prisma.ts
ui
src/components/ui/
,
src/components/
layout
(front)/layout.tsx
,
(auth)/layout.tsx
api
src/app/api/
config
next.config.ts
,
prisma.config.ts
,
.env
范围对应代码位置
auth
src/lib/auth.ts
,
src/lib/auth-client.ts
,
(auth)/
路由
product
(front)/product/
,
app-product-card.tsx
cart
src/lib/cart-store.ts
, 购物车相关组件
course
(front)/course/
,
src/services/course-service.ts
contact
(front)/contact/
,
src/app/api/contact/
prisma
prisma/schema.prisma
,
src/lib/prisma.ts
ui
src/components/ui/
,
src/components/
layout
(front)/layout.tsx
,
(auth)/layout.tsx
api
src/app/api/
config
next.config.ts
,
prisma.config.ts
,
.env

Subject Rules

主题规则

  • ใช้อังกฤษเท่านั้น
  • ประโยคสั้นๆ ไม่เกิน 72 ตัวอักษร
  • ไม่ต้องมี period ท้ายประโยค
  • ใช้ present tense: "add", "fix", "update" ไม่ใช่ "added", "fixed"
  • ใช้อังกฤษเท่านั้น
  • ประโยคสั้นๆ ไม่เกิน 72 ตัวอักษร
  • ไม่ต้องมี period ท้ายประโยค
  • 使用一般现在时:"add"、"fix"、"update",而非"added"、"fixed"

Examples

示例

feat(product): add product detail page
fix(cart): fix totalPrice calculation when qty is 0
chore(prisma): regenerate Prisma client after schema changes
style(ui): update badge color in hero component
refactor(auth): extract signIn logic from page component
feat(api): add GET /api/products endpoint with pagination
fix(contact): prevent XSS in email HTML template
feat(product): add product detail page
fix(cart): fix totalPrice calculation when qty is 0
chore(prisma): regenerate Prisma client after schema changes
style(ui): update badge color in hero component
refactor(auth): extract signIn logic from page component
feat(api): add GET /api/products endpoint with pagination
fix(contact): prevent XSS in email HTML template

Gotchas

注意事项

  • ห้าม commit ไฟล์
    .env
    — มี
    BETTER_AUTH_SECRET
    และ
    DATABASE_URL
  • ไฟล์
    generated/prisma/
    ถูก gitignore — ไม่ต้อง stage
  • ถ้าแก้ schema แล้วต้อง
    npx prisma generate
    ก่อน commit ตัว schema
  • ไม่ใช้
    --no-verify
    เพื่อข้าม hook โดยไม่มีเหตุผล
  • ห้าม commit ไฟล์
    .env
    — มี
    BETTER_AUTH_SECRET
    และ
    DATABASE_URL
  • generated/prisma/
    目录已被gitignore — 无需暂存
  • 如果修改了schema,提交前必须执行
    npx prisma generate
  • 无正当理由不得使用
    --no-verify
    跳过钩子

Checklist Before Committing

提交前检查清单

  • ไม่มีไฟล์
    .env
    หรือ secret ใน staging area
  • npm run lint
    ผ่านโดยไม่มี error
  • Type ใหม่อยู่ใน
    src/types/
    ไม่ใช่ inline ใน component
  • ไฟล์ชื่อ kebab-case เช่น
    product-service.ts
  • 暂存区中没有
    .env
    文件或敏感信息
  • npm run lint
    执行通过,无错误
  • 新类型定义在
    src/types/
    目录中,而非内联在组件中
  • 文件名采用kebab-case格式,例如
    product-service.ts