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 and develop

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 feature
  • fix: Bug fix
  • docs: Documentation changes
  • style: Code style changes (formatting, etc.)
  • refactor: Code refactoring
  • test: Test additions or modifications
  • chore: 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 tests
  • main 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.