
# Cara Baik Dalam Menulis Git Commit Message
Table of Contents
Commit message yang rapi, benar, dan menarik biasanya mengikuti beberapa prinsip standar, seperti Conventional Commits atau gaya lain yang memudahkan tracking perubahan.
1. Struktur Commit Message yang Baik
Format yang umum digunakan:
<type>(<scope>): <subject>
<body> (Opsional)<footer> (Opsional)
type
→ Jenis perubahan yang dilakukanscope
→ Bagian kode yang terpengaruh (opsional)subject
→ Deskripsi singkat perubahanbody
→ Penjelasan tambahan (opsional, untuk perubahan kompleks)footer
→ Info tambahan (opsional, misal: issue tracker, breaking changes)
2. Jenis Commit Message (Type)
Gunakan kata kerja yang deskriptif dan sesuai dengan perubahan yang dilakukan:
Type | Keterangan | Contoh |
---|---|---|
feat | Menambahkan fitur baru | feat(auth): add Google login |
fix | Memperbaiki bug | fix(cart): resolve checkout error |
refactor | Refactoring kode tanpa mengubah fungsionalitas | refactor(api): improve response structure |
chore | Perubahan yang tidak mempengaruhi kode produksi | chore: update dependencies |
docs | Perubahan pada dokumentasi | docs(readme): update setup instructions |
test | Menambahkan atau memperbaiki pengujian | test(unit): add test cases for login |
style | Perubahan terkait format (spasi, indentasi) | style: fix eslint warnings |
perf | Optimasi performa | perf(api): reduce response time |
ci | Perubahan pada CI/CD pipeline | ci(github): update workflow |
revert | Membatalkan commit sebelumnya | revert: rollback login feature |
3. Contoh Commit Message yang Rapi
Commit kecil (1 baris)
feat(profile): add profile picture upload
Commit dengan deskripsi lebih detail
feat(auth): add Google login
- Implement Google OAuth using Firebase- Store user token securely- Update UI for login flow
Closes #42
Commit untuk bug fix
fix(cart): resolve checkout error
Fix an issue where users couldn't complete checkoutdue to missing product ID in API request.
4. Tips Tambahan
✅ Gunakan kalimat aktif → “Add feature” lebih baik daripada “Feature added”
✅ Hindari commit tidak jelas → fix bug
terlalu umum
✅ Satu commit, satu perubahan → Jangan campur “fix” dan “feat” dalam satu commit
✅ Gunakan emoji (opsional) untuk membuat commit lebih menarik
Emoji | Commit Type | Contoh |
---|---|---|
🎉 | Fitur baru | feat: 🎉 initial project setup |
🔥 | Hapus kode | chore: 🔥 remove unused functions |
🐛 | Perbaikan bug | fix: 🐛 resolve login issue |
📝 | Dokumentasi | docs: 📝 update API docs |
🚀 | Optimasi | perf: 🚀 improve image loading speed |