Git Workflow Guide
Workflow Comparison
| Workflow | Best For | Complexity |
|---|---|---|
| Feature Branch | Most teams | Low |
| Gitflow | Versioned releases | High |
| Trunk-based | CI/CD, large teams | Medium |
| GitHub Flow | Continuous deployment | Low |
Feature Branch Workflow
# Create feature branch
git checkout main && git pull
git checkout -b feature/user-auth
# Work and commit
git add -p # stage interactively
git commit -m "feat: add JWT authentication"
# Keep branch updated
git fetch origin
git rebase origin/main
# Push and create PR
git push origin feature/user-auth
Gitflow Branches
| Branch | Purpose | Lifetime |
|---|---|---|
| main | Production code | Permanent |
| develop | Integration branch | Permanent |
| feature/* | New features | Until merged |
| release/* | Release preparation | Until released |
| hotfix/* | Production fixes | Until merged |
Conventional Commits
feat: A new feature
fix: A bug fix
docs: Documentation only
style: Formatting, no logic change
refactor: Code refactoring
test: Adding tests
chore: Build process or tooling
perf: Performance improvement
# Examples
feat(auth): add OAuth2 login with Google
fix(api): handle null response from payment service
docs(readme): update installation instructions
feat!: breaking change โ remove deprecated API