Labs ICT
โญ Pro Login

Version Control Strategies

Branching models, merge strategies, and version control workflows.

Version Control Strategies

Version control strategies define how teams organize, merge, and manage code changes. A good strategy keeps the codebase stable while enabling parallel development.

Branching Models


  +---------------------------------------------------------+
  |            VERSION CONTROL STRATEGIES                    |
  +---------------------------------------------------------+
  |                                                         |
  |   GIT FLOW                                              |
  |   - main: production-ready code                         |
  |   - develop: integration branch                         |
  |   - feature/*: new features                             |
  |   - release/*: prepare releases                         |
  |   - hotfix/*: urgent fixes                              |
  |                                                         |
  |   GITHUB FLOW                                           |
  |   - main: always deployable                             |
  |   - feature branches: short-lived                       |
  |   - Pull requests for all changes                       |
  |   - Simpler,้€‚ๅˆ continuous deployment                   |
  |                                                         |
  |   TRUNK-BASED                                           |
  |   - Single main branch                                  |
  |   - Short-lived feature branches (< 1 day)              |
  |   - Feature flags for incomplete work                   |
  |   - Best for CI/CD                                      |
  |                                                         |
  +---------------------------------------------------------+

Git Flow Example


  # Create a feature branch
  git checkout develop
  git checkout -b feature/user-authentication

  # Work on feature
  git add .
  git commit -m "Add login form"

  # Finish feature
  git checkout develop
  git merge --no-ff feature/user-authentication
  git branch -d feature/user-authentication

  # Prepare release
  git checkout -b release/1.0.0 develop
  # test, fix bugs
  git checkout main
  git merge --no-ff release/1.0.0
  git tag -a v1.0.0 -m "Release 1.0.0"
  git checkout develop
  git merge --no-ff release/1.0.0

Merge Strategies

  • Fast-Forward: Linear merge when no divergent commits
  • Recursive: Creates a new merge commit from two parents
  • Squash: Combines all commits into one before merging
  • Rebase: Replays commits on top of another branch

Key Takeaways

  • Choose a branching strategy that fits your team's workflow
  • Git Flow is best for scheduled releases
  • GitHub Flow and Trunk-Based are best for continuous deployment
  • Keep branches short-lived to minimize merge conflicts

๐Ÿงช Quick Quiz

What is the Git Flow branching model?