Branching Strategy
Branching Strategy
Section titled “Branching Strategy”Panduan untuk Git branching dan workflow pengembangan di Merq.
Overview
Section titled “Overview”Merq menggunakan Git untuk version control dengan struktur branch yang terstruktur.
Branch Types
Section titled “Branch Types”Main Branches
Section titled “Main Branches”| Branch | Environment | Purpose |
|---|---|---|
main | Production | Stable, deployable code |
staging | Staging | Pre-production testing |
dev | Development | Integration branch |
Supporting Branches
Section titled “Supporting Branches”| Branch | Prefix | Purpose |
|---|---|---|
| Feature | feature/ | New functionality |
| Bug Fix | bugfix/ | Non-critical bug fixes |
| Hotfix | hotfix/ | Critical production fixes |
| Release | rc/ | Release candidates |
Branch Diagram
Section titled “Branch Diagram” ┌─────────────┐ │ main │ ◄── Production └──────┬──────┘ │ ┌──────▼──────┐ │ ◄── Pre-production └──── staging │──┬──────┘ │ ┌────────────┴────────────┐ │ │ ┌─────▼─────┐ ┌──────▼──────┐ │ feature/001 │ │ bugfix/002 │ │ login │ │ dashboard │ └─────┬─────┘ └──────┬──────┘ │ │ └────────────┬────────────┘ │ ┌──────▼──────┐ │ dev │ ◄── Development └─────────────┘Naming Conventions
Section titled “Naming Conventions”Feature Branches
Section titled “Feature Branches”feature/<number>-<description>Examples:
feature/001-user-authenticationfeature/002-outlet-mappingfeature/003-push-notificationsBug Fix Branches
Section titled “Bug Fix Branches”bugfix/<description>Examples:
bugfix/login-redirect-issuebugfix/pagination-not-workingbugfix/missing-validationHotfix Branches
Section titled “Hotfix Branches”hotfix/<description>Examples:
hotfix/security-patchhotfix/database-connectionhotfix/production-crashRelease Candidate Branches
Section titled “Release Candidate Branches”rc/<version>Examples:
rc/1.0.0rc/1.2.0-betaWorkflow
Section titled “Workflow”1. New Feature
Section titled “1. New Feature”# 1. Update dev branchgit checkout devgit pull origin dev
# 2. Create feature branchgit checkout -b feature/001-new-feature
# 3. Develop and commitgit add .git commit -m "feat: add new feature"
# 4. Push to remotegit push origin feature/001-new-feature
# 5. Create Pull Request# Target: dev branch2. Bug Fix (Non-Critical)
Section titled “2. Bug Fix (Non-Critical)”# 1. Create branch from devgit checkout devgit pull origin devgit checkout -b bugfix/fix-description
# 2. Fix and commitgit add .git commit -m "fix: resolve issue description"
# 3. Push and create PRgit push origin bugfix/fix-description# PR to: dev3. Hotfix (Critical Production)
Section titled “3. Hotfix (Critical Production)”# 1. Create branch from maingit checkout maingit pull origin maingit checkout -b hotfix/critical-fix
# 2. Fix and commitgit add .git commit -m "hotfix: critical fix description"
# 3. Push and create PRgit push origin hotfix/critical-fix
# PR to: main (also cherry-pick to dev)4. Release
Section titled “4. Release”# 1. Create RC branch from devgit checkout devgit pull origin devgit checkout -b rc/1.0.0
# 2. Final testing and fixes# No new features!
# 3. Merge to staging for testinggit checkout staginggit merge rc/1.0.0
# 4. After testing, merge to maingit checkout maingit merge rc/1.0.0
# 5. Tag the releasegit tag -a v1.0.0 -m "Release version 1.0.0"git push origin v1.0.0Pull Request Rules
Section titled “Pull Request Rules”Requirements
Section titled “Requirements”- Minimum 1 reviewer approved
- All CI checks passed
- No merge conflicts
- Tests passing (if applicable)
PR Title Format
Section titled “PR Title Format”<type>: <description>
Types: feat, fix, hotfix, refactor, docs, choreExamples:
feat: add user authentication flowfix: resolve pagination issue in outlets listhotfix: critical security patchdocs: update API documentationCommit Message Format
Section titled “Commit Message Format”<type>(<scope>): <description>
Types: feat, fix, docs, style, refactor, test, choreExamples:
feat(auth): add JWT token refreshfix(handlers): resolve nil pointer in user handlerdocs(readme): update installation stepsProtected Branches
Section titled “Protected Branches”| Branch | Who Can Push | Who Can Merge |
|---|---|---|
main | CI/CD only | Maintainers |
staging | CI/CD | Maintainers |
dev | Developers | Maintainers |
Feature Numbering
Section titled “Feature Numbering”Gunakan issue tracker atau task management untuk feature numbers:
feature/001-user-loginfeature/002-user-registrationfeature/003-password-reset...Increment number untuk setiap feature baru.
Best Practices
Section titled “Best Practices”-
Branch dari branch yang benar
- Features → dari
dev - Bug fixes → dari
dev - Hotfixes → dari
main
- Features → dari
-
Buat branch kecil dan sering
- Setiap branch harus menyelesaikan satu masalah
- Lebih mudah di-review dan di-merge
-
Commit sering
- Commit early, commit often
- Setiap commit harus masuk akal secara independen
-
Update branch secara berkala
- Rebase dari parent branch secara berkala
- Hindari merge conflict yang besar
-
Hapus branch setelah merge
- Branch yang sudah di-merge harus dihapus
- Jaga repository tetap bersih
Quick Reference
Section titled “Quick Reference”# Update devgit checkout dev && git pull
# Create featuregit checkout -b feature/001-my-feature
# Create bugfixgit checkout -b bugfix/my-fix
# Create hotfixgit checkout main && git pull && git checkout -b hotfix/my-fix
# Interactive rebase (sebelum push)git rebase -i HEAD~3
# Cherry-pick commit ke branch laingit cherry-pick <commit-hash>