🌿 Aturan Git

Aturan Branch & Commit

Kebijakan Git untuk tim backend

Branching Model

Jenis Branch Yang Ada

Main Branches:
main - Branch production yang stabil
dev - Branch devment terbaru
Supporting Branches:
feature/[modul] - Branch fitur baru
hotfix/[nama-fix] - Branch perbaikan bug urgent
release/[versi] - Branch persiapan release

🖼️ Ilustrasi Branching Model:

Git Branching Model

📝 Aturan Branch:

Feature Branch: feature/[nomor-modul]

Misal: feature/1, feature/2

Branch dari: Selalu buat dari dev
Merge ke: Selalu merge ke dev
Durasi: Satu branch maksimal 3 hari kerja

✅ Contoh Workflow:

# 1. Pastikan di branch dev
git checkout dev
git pull origin dev

# 2. Buat branch fitur baru
git checkout -b feature/1

# 3. Kerjakan kode, lalu commit
git add .
git commit -m "feat: tambah endpoint user registration"

# 4. Push ke remote branch
git push -u origin feature/1

# 5. Buat Pull Request ke dev
# 6. Tunggu review & merge

Aturan Commit Message

Format Commit Message

[type]: [deskripsi singkat]
  • type: feat, fix, docs, style, refactor, test, chore
  • deskripsi: Dalam bahasa Indonesia, maksimal 50 karakter

🏷️ Kategori Commit:

Tipe Kegunaan Contoh
feat Fitur baru feat: tambah validasi email
fix Perbaikan bug fix: perbaiki error login
docs Dokumentasi docs: update README
refactor Perubahan kode tanpa mengubah fungsi refactor: optimasi query database

✅ Contoh Commit yang Baik:

feat: tambah endpoint forgot password
- Tambah route POST /api/forgot-password
- Buat ForgotPasswordRequest untuk validasi
- Integrasi dengan service kirim email
fix: perbaiki validasi register duplikat email
- Cek email sudah ada sebelum create user
- Return error message yang jelas

❌ Contoh Commit yang Buruk:

update code // ❌ Tidak jelas apa yang diubah
feat: fix bug and add feature // ❌ Banyak perubahan dalam 1 commit

Alur Kerja Harian

🔄 Daily Git Workflow:

  1. 1

    Pagi hari: Pull branch dev terbaru

  2. 2

    Mulai kerja: Buat branch feature/[nomor] dari dev

  3. 3

    Selama coding: Commit perubahan kecil tapi bermakna

  4. 4

    Selesai modul: Push branch dan buat Pull Request

  5. 5

    Sore hari: Pastikan semua tests pass dan code review selesai

Tips untuk Pemula

  • • Selalu work di branch sendiri, jangan langsung di dev
  • • Commit sering tapi bermakna - setiap perubahan logic
  • • Push minimal 2x sehari, sebelum pulang kerja
  • • Jangan takut salah, bisa di-revert/rebase
Kembali