Git Branching Strategy
This repository follows a GitHub Flow inspired branching strategy optimized for continuous deployment and portfolio development.
Branch Structure
๐ Main Branches
main
- Purpose: Production-ready code
- Protection: Protected branch with required reviews
- Deployment: Automatically deploys to https://colinrey.ch via GitHub Actions
- Updates: Only via pull requests from
develop
develop
- Purpose: Integration branch for ongoing development
- Testing: Pre-production testing and feature integration
- Stability: Should always be in a deployable state
- Updates: Merges from feature branches, PRs to
main
๐ Supporting Branches
Feature Branches (feature/feature-name
)
- Naming:
feature/add-blog-section
,feature/contact-form
- Lifespan: Short-lived, deleted after merge
- Origin: Branched from
develop
- Merge: Back to
develop
via Pull Request
Hotfix Branches (hotfix/fix-name
)
- Naming:
hotfix/fix-navbar-mobile
,hotfix/ssl-redirect
- Purpose: Critical fixes for production
- Origin: Branched from
main
- Merge: To both
main
anddevelop
Workflow Examples
๐ Feature Development
# Start new feature
git checkout develop
git pull origin develop
git checkout -b feature/add-blog-section
# Work on feature
git add .
git commit -m "Add blog section layout"
git push -u origin feature/add-blog-section
# Create PR: feature/add-blog-section โ develop
# After approval and merge, delete feature branch
๐จ Hotfix Process
# Critical fix needed
git checkout main
git pull origin main
git checkout -b hotfix/fix-mobile-nav
# Fix the issue
git add .
git commit -m "Fix mobile navigation toggle"
git push -u origin hotfix/fix-mobile-nav
# Create PR: hotfix/fix-mobile-nav โ main
# Also merge to develop to keep branches in sync
๐ฆ Release Process
# When develop is ready for release
# Create PR: develop โ main
# After approval, main auto-deploys to production
Branch Protection Rules
Main Branch
- โ Require pull request reviews
- โ Require status checks to pass
- โ Require branches to be up to date
- โ Require linear history
- โ Restrict force pushes
Develop Branch
- โ Require pull request reviews (optional)
- โ Allow force pushes for maintainers
- โ Delete head branches after merge
Commit Guidelines
Format
<type>(<scope>): <description>
[optional body]
[optional footer]
Types
feat
: New featurefix
: Bug fixdocs
: Documentation changesstyle
: Code style changes (formatting, etc.)refactor
: Code refactoringtest
: Test additions or modificationschore
: Maintenance tasks
Examples
feat(portfolio): add project filtering functionality
fix(navigation): resolve mobile menu toggle issue
docs(readme): update installation instructions
style(scss): improve button hover animations
Best Practices
๐ Pull Requests
- Clear, descriptive titles
- Detailed description of changes
- Reference related issues
- Include screenshots for UI changes
- Keep PRs focused and small
๐งน Branch Hygiene
- Delete merged feature branches
- Regularly sync with upstream branches
- Use descriptive branch names
- Keep commits atomic and focused
๐ Continuous Integration
- All branches run automated tests
develop
includes integration testsmain
deploys automatically on merge- Failed checks block merge
Quick Commands
# Create feature branch
git checkout develop && git pull && git checkout -b feature/my-feature
# Sync develop with latest changes
git checkout develop && git pull origin develop
# Clean up merged branches
git branch --merged | grep -v "\*\|main\|develop" | xargs git branch -d
# View branch status
git branch -vv
This strategy ensures code quality, enables parallel development, and maintains a stable production environment.