Git Branch Strategies
Common Git branching models and workflow strategies.
Git Flow
Main branches
main // Production-ready code
develop // Integration branch
Supporting branches
feature/* // New features
release/* // Release preparation
hotfix/* // Quick production fixes
Create feature branch
git checkout develop
git checkout -b feature/new-feature
Finish feature
git checkout develop
git merge --no-ff feature/new-feature
git branch -d feature/new-feature
Create release branch
git checkout develop
git checkout -b release/1.2.0
GitHub Flow
Simple workflow
1. Create branch from main
2. Add commits
3. Open Pull Request
4. Review and discuss
5. Deploy and test
6. Merge to main
Create feature branch
git checkout main
git pull origin main
git checkout -b feature-name
Push and create PR
git push -u origin feature-name
Then create PR on GitHub
After merge, cleanup
git checkout main
git pull origin main
git branch -d feature-name
Trunk-Based Development
Key principles
• All developers work on trunk (main)
• Short-lived feature branches (< 1 day)
• Frequent integration (multiple times per day)
• Feature flags for incomplete work
• CI/CD pipeline required
Quick feature workflow
git checkout main
git pull --rebase
git checkout -b short-feature
// Make small changes
git commit -am "feat: add feature"
git checkout main
git merge short-feature
git push
Release branches
git checkout -b release/v1.0 main
// Only bug fixes on release branch
Branch Naming Conventions
Feature branches
feature/user-authentication
feature/add-payment-gateway
feat/search-functionality
Bug fix branches
bugfix/fix-login-error
fix/correct-calculation
bug/header-alignment
Hotfix branches
hotfix/critical-security-patch
hotfix/production-crash
Release branches
release/1.0.0
release/v2.1
Other types
docs/update-readme
refactor/cleanup-code
test/add-unit-tests
chore/update-dependencies