Skip to content

Branching Strategy

Panduan untuk Git branching dan workflow pengembangan di Merq.

Merq menggunakan Git untuk version control dengan struktur branch yang terstruktur.

BranchEnvironmentPurpose
mainProductionStable, deployable code
stagingStagingPre-production testing
devDevelopmentIntegration branch
BranchPrefixPurpose
Featurefeature/New functionality
Bug Fixbugfix/Non-critical bug fixes
Hotfixhotfix/Critical production fixes
Releaserc/Release candidates
┌─────────────┐
│ main │ ◄── Production
└──────┬──────┘
┌──────▼──────┐
│ ◄── Pre-production
└──── staging │──┬──────┘
┌────────────┴────────────┐
│ │
┌─────▼─────┐ ┌──────▼──────┐
│ feature/001 │ │ bugfix/002 │
│ login │ │ dashboard │
└─────┬─────┘ └──────┬──────┘
│ │
└────────────┬────────────┘
┌──────▼──────┐
│ dev │ ◄── Development
└─────────────┘
feature/<number>-<description>

Examples:

feature/001-user-authentication
feature/002-outlet-mapping
feature/003-push-notifications
bugfix/<description>

Examples:

bugfix/login-redirect-issue
bugfix/pagination-not-working
bugfix/missing-validation
hotfix/<description>

Examples:

hotfix/security-patch
hotfix/database-connection
hotfix/production-crash
rc/<version>

Examples:

rc/1.0.0
rc/1.2.0-beta
Terminal window
# 1. Update dev branch
git checkout dev
git pull origin dev
# 2. Create feature branch
git checkout -b feature/001-new-feature
# 3. Develop and commit
git add .
git commit -m "feat: add new feature"
# 4. Push to remote
git push origin feature/001-new-feature
# 5. Create Pull Request
# Target: dev branch
Terminal window
# 1. Create branch from dev
git checkout dev
git pull origin dev
git checkout -b bugfix/fix-description
# 2. Fix and commit
git add .
git commit -m "fix: resolve issue description"
# 3. Push and create PR
git push origin bugfix/fix-description
# PR to: dev
Terminal window
# 1. Create branch from main
git checkout main
git pull origin main
git checkout -b hotfix/critical-fix
# 2. Fix and commit
git add .
git commit -m "hotfix: critical fix description"
# 3. Push and create PR
git push origin hotfix/critical-fix
# PR to: main (also cherry-pick to dev)
Terminal window
# 1. Create RC branch from dev
git checkout dev
git pull origin dev
git checkout -b rc/1.0.0
# 2. Final testing and fixes
# No new features!
# 3. Merge to staging for testing
git checkout staging
git merge rc/1.0.0
# 4. After testing, merge to main
git checkout main
git merge rc/1.0.0
# 5. Tag the release
git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0
  • Minimum 1 reviewer approved
  • All CI checks passed
  • No merge conflicts
  • Tests passing (if applicable)
<type>: <description>
Types: feat, fix, hotfix, refactor, docs, chore

Examples:

feat: add user authentication flow
fix: resolve pagination issue in outlets list
hotfix: critical security patch
docs: update API documentation
<type>(<scope>): <description>
Types: feat, fix, docs, style, refactor, test, chore

Examples:

feat(auth): add JWT token refresh
fix(handlers): resolve nil pointer in user handler
docs(readme): update installation steps
BranchWho Can PushWho Can Merge
mainCI/CD onlyMaintainers
stagingCI/CDMaintainers
devDevelopersMaintainers

Gunakan issue tracker atau task management untuk feature numbers:

feature/001-user-login
feature/002-user-registration
feature/003-password-reset
...

Increment number untuk setiap feature baru.

  1. Branch dari branch yang benar

    • Features → dari dev
    • Bug fixes → dari dev
    • Hotfixes → dari main
  2. Buat branch kecil dan sering

    • Setiap branch harus menyelesaikan satu masalah
    • Lebih mudah di-review dan di-merge
  3. Commit sering

    • Commit early, commit often
    • Setiap commit harus masuk akal secara independen
  4. Update branch secara berkala

    • Rebase dari parent branch secara berkala
    • Hindari merge conflict yang besar
  5. Hapus branch setelah merge

    • Branch yang sudah di-merge harus dihapus
    • Jaga repository tetap bersih
Terminal window
# Update dev
git checkout dev && git pull
# Create feature
git checkout -b feature/001-my-feature
# Create bugfix
git checkout -b bugfix/my-fix
# Create hotfix
git checkout main && git pull && git checkout -b hotfix/my-fix
# Interactive rebase (sebelum push)
git rebase -i HEAD~3
# Cherry-pick commit ke branch lain
git cherry-pick <commit-hash>