Git Convention Commits Specification

November 19, 2025

1. Cấu trúc cơ bản của Commit Message

Commit Message thường có cấu trúc như sau

<Type>(Scope)!: (Subject)

  • Type: required, xác định loại thay đổi như feat, fix, refactor
  • Scope: optional, chỉ ra phần nào codebase ảnh hưởng như api , ui, auth. Đặt trong dấu ()
  • ! (Break Change): optional. Báo hiệu rằng đây là một thay đổi phá vở tương thích. (Quan trọng, nghiêm trọng), ít dùng lắm.
  • Subject: required. Mô tả ngắn gọn, thường không quá 50 ký tự.

2. Type Prefixes

Dưới đây là các tiếp đầu ngữ (type) thông dụng theo Conventional Commits:

TypeCommit TypeExample
featThêm một tính năng mới (Feature).feat(auth): thêm đăng nhập bằng Google
fixBug fix.fix(core): fix convert date to string
refactorrefactor code, no change features .refactor(utils): using Extension Methods
choremaintain: update dependencies, config build.chore: update phiên bản npm lên 10.1
docsDocumentation.docs(readme): thêm hướng dẫn cài đặt local
stylecode style: remove trailing spacesstyle(layout): áp dụng prettier cho toàn bộ css
testTeststest: thêm unit test cho chức năng giỏ hàng
perfThay đổi cải thiện hiệu suất (Performance).perf(image): tối ưu hóa thuật toán nén ảnh
buildBuild: npm, dotnetbuild: cập nhật webpack.config.js
ci(CI) như GitHub Actions, Jenkins.ci: thêm job kiểm tra linting tự động

3. Git Command

  • Create a feature branch

git checkout -b feature/oauth-integration

  • Pull codes

git pull --rebase

  • Merge master into your branch

git pull --rebase
git rebase master

  • Git push

git push --force-with-lease

4. Notes when commit

  • Do not commit: token, password, secret keys, public API
  • Should use environment variables