- Branching strategy for Git
- Created by Vincent Driessen
- Ideal for release-based workflows
- Provides structured approach to version control
- Production-ready code
- Contains released versions
- Never receives direct commits
- Tagged with version numbers
- Integration branch
- Source of latest development changes
- Where features come together
git checkout -b feature/new-feature develop
# work on feature
git merge --no-ff feature/new-feature
git checkout -b release-1.2 develop
# prepare release
git merge --no-ff release-1.2
git checkout -b hotfix-1.2.1 main
# fix critical bug
git merge --no-ff hotfix-1.2.1
-
Feature
- Start: branch from develop
- End: merge to develop
-
Release
- Start: branch from develop
- End: merge to main & develop
-
Hotfix
- Start: branch from main
- End: merge to main & develop
- Never commit to main directly
- Use meaningful branch names
- Delete branches after merging
- Always use
--no-ff
for merges - Tag all releases
- Clear release cycle
- Parallel development
- Organized codebase
- Emergency fixes possible
- Supports team collaboration
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
feat
: New featuresfix
: Bug fixesrefactor
: Code restructuringdocs
: Documentation updatesstyle
: Code formattingtest
: Test-related changes
auth
: Authentication/Authorizationapi
: API endpoints/logicui
: User interfacecore
: Core functionalitydb
: Database related
feature/ # New features
bugfix/ # Bug fixes
hotfix/ # Urgent fixes for production
release/ # Release preparation
docs/ # Documentation updates
# Format
<type>/<ticket-number>-<brief-description>
# Examples
feature/AUTH-123-google-login
bugfix/UI-456-nav-alignment
hotfix/API-789-memory-leak
# Update main branch
git checkout main
git pull --rebase origin main
# Create feature branch
git checkout -b feature/AUTH-123-google-login
# Create bugfix branch
git checkout -b bugfix/UI-456-nav-alignment
# Start of day
git checkout main
git pull --rebase origin main
git checkout feature/AUTH-123-google-login
git rebase main
# During development
git add <files>
git commit -m "feat(auth): implement Google OAuth flow
- Add OAuth2.0 client
- Implement token handling
- Add user profile mapping
Relates to AUTH-123"
# Update with latest changes
git checkout main
git pull --rebase origin main
git checkout feature/AUTH-123-google-login
git rebase main
# Review commits
git log --oneline main..HEAD
# Push changes
git push origin feature/AUTH-123-google-login
# Initial setup
git commit -m "feat(auth): add Google OAuth structure
- Create service interfaces
- Add configuration templates
- Setup basic components"
# Implementation
git commit -m "feat(auth): implement OAuth login flow
- Add token handling
- Implement user mapping
- Add error handling"
# Testing
git commit -m "test(auth): add OAuth integration tests
- Add service mocks
- Test success flows
- Test error scenarios"
# Documentation
git commit -m "docs(auth): add OAuth setup guide
- Add configuration steps
- Document API usage
- Include examples"
# Investigation commit
git commit -m "test(ui): reproduce navigation bug
- Add failing test case
- Document expected behavior
- Track related issues"
# Fix implementation
git commit -m "fix(ui): resolve navigation state sync
- Update state management
- Fix event handlers
- Add validation checks"
# Verification
git commit -m "test(ui): verify navigation fix
- Add regression tests
- Update existing tests
- Document edge cases"
✅ DO:
feat(auth): implement password reset flow
fix(api): handle null response from payment service
docs(readme): update deployment instructions
❌ DON'T:
update code
fix bug
WIP
✅ DO:
- Keep branches focused and small
- Regularly rebase with main
- Delete branches after merging
❌ DON'T:
- Mix multiple features in one branch
- Keep stale branches
- Push directly to main
✅ DO:
- Group related changes
- Include tests with features
- Update documentation
❌ DON'T:
- Mix unrelated changes
- Skip tests
- Leave TODO comments
# Run tests
npm run test
# Check linting
npm run lint
# Build verification
npm run build
# Update with main
git rebase main
# Review changes
git log --oneline main..HEAD
git diff main
# Verify commit messages
git log --pretty=format:"%h %s"
- All tests passing
- Documentation updated
- No debug code
- Commit messages follow convention
- Branch rebased with main
- Wrong Branch Base
# Check current base
git merge-base HEAD main
# Rebase if needed
git rebase main
- Messy Commit History
# Interactive rebase to clean up
git rebase -i main
- Conflict Resolution
# During rebase
git rebase main
# If conflicts occur
git status
# Fix conflicts
git add <resolved-files>
git rebase --continue
Remember: The goal is to maintain a clean, traceable history while making the code review process efficient and effective.
Contact: Md Sohel Mia