Kembali ke Blog
Tutorial#git#workflow#tim#developer#collaboration

Git Workflow untuk Tim: Cara Kolaborasi Kode yang Rapi dan Tidak Berantakan

Banyak tim developer yang berantakan karena tidak punya Git workflow yang jelas. Conflict terus, branch kacau, dan tidak ada yang tahu kode siapa yang benar. Ini cara yang benar.

Muhamad Putra Aulia Hidayat

Muhamad Putra Aulia Hidayat

25 Maret 20263 menit baca

Git Workflow untuk Tim Developer

Git itu powerful, tapi kalau tidak ada convention yang disepakati, hasilnya chaos. Ini workflow yang kami pakai dan sudah terbukti bekerja di tim kecil maupun besar.

Branching Strategy: GitHub Flow

Ada beberapa strategi populer: Git Flow, GitHub Flow, Trunk-based Development. Untuk kebanyakan tim, GitHub Flow adalah sweet spot:

main (production)
  ├── feature/user-auth
  ├── feature/payment-integration
  ├── fix/login-bug
  └── chore/update-dependencies

Aturannya simpel:

  1. main selalu production-ready
  2. Semua development di branch terpisah
  3. Merge via Pull Request
  4. Deploy langsung setelah merge ke main

Naming Convention Branch

# Format: type/deskripsi-singkat
feature/add-payment-gateway
feature/user-profile-page
fix/cart-total-calculation
fix/mobile-navbar-overlap
chore/upgrade-nextjs-16
chore/add-eslint-rules
docs/api-documentation
refactor/auth-middleware

Commit Message yang Bermakna

Pakai Conventional Commits — format standar yang bisa auto-generate changelog:

# Format: type(scope): deskripsi

# Feature baru
git commit -m "feat(auth): add Google OAuth login"

# Bug fix
git commit -m "fix(cart): calculate discount before tax"

# Breaking change
git commit -m "feat(api)!: change response format to snake_case"

# Tanpa scope
git commit -m "docs: update README with deployment steps"

Types yang valid: feat, fix, docs, style, refactor, test, chore, perf

Setup Git Hooks dengan Husky

npm install --save-dev husky lint-staged
npx husky init
# .husky/pre-commit
npx lint-staged
// package.json
{
  "lint-staged": {
    "*.{ts,tsx}": ["eslint --fix", "prettier --write"],
    "*.{css,json,md}": ["prettier --write"]
  }
}

Sekarang setiap commit otomatis di-lint dan di-format.

Pull Request Template

<!-- .github/PULL_REQUEST_TEMPLATE.md -->
## Perubahan yang Dilakukan
- [ ] Deskripsi singkat perubahan

## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation

## Cara Test
1. Langkah pertama
2. Langkah kedua

## Screenshots (kalau ada UI change)

## Checklist
- [ ] Kode sudah di-review sendiri
- [ ] Tidak ada console.log yang tertinggal
- [ ] Unit test sudah lulus

Mengatasi Merge Conflict

# Update branch dari main sebelum PR
git checkout feature/my-feature
git fetch origin
git rebase origin/main

# Kalau ada conflict
# Edit file yang conflict, hapus marker <<<, ===, >>>
git add .
git rebase --continue

# Jika stuck, batalkan rebase
git rebase --abort

Git Aliases yang Berguna

# ~/.gitconfig
[alias]
  lg = log --oneline --graph --decorate --all
  undo = reset --soft HEAD~1
  wip = commit -am "WIP: work in progress"
  aliases = config --get-regexp alias
  branches = branch -a --sort=-committerdate

# Pakai:
git lg          # Visual log
git undo        # Batalkan commit terakhir (keep changes)
git wip         # Quick save progress

Squash Before Merge

# Squash 5 commit terakhir jadi satu
git rebase -i HEAD~5

# Ganti semua "pick" jadi "squash" kecuali yang pertama
# Tulis commit message yang meaningful

PR yang masuk ke main idealnya satu commit per fitur — histori jadi bersih dan mudah di-bisect kalau ada bug.

gitworkflowtimdevelopercollaboration

Newsletter Digital Uptime

Tips teknologi & bisnis mingguan

Bergabung dengan 2,500+ subscriber yang mendapatkan insight teknologi, tutorial development, dan tips bisnis digital langsung ke inbox mereka setiap minggu.

Tidak ada spam. Unsubscribe kapan saja.

Artikel Terkait

Kami menggunakan cookies untuk meningkatkan pengalaman Anda di website ini. Dengan melanjutkan, Anda menyetujui penggunaan cookies sesuai Kebijakan Privasi kami.