Branching Strategies

Overview

In this lab you will explore common Git branching strategies and apply them in practice. Understanding branching models is essential for the CI/CD workflows you will build in later labs.

Branching Models

Trunk-Based Development

  • All developers commit to a single main branch

  • Short-lived feature branches merged frequently

  • Best suited for teams practicing continuous delivery

GitFlow

  • Separate branches for features, releases, and hotfixes

  • Well-defined promotion path from development to production

  • Suited for teams with scheduled release cycles

GitHub Flow

  • Simplified model with a single main branch and feature branches

  • Pull requests trigger CI and review before merging

  • Ideal for continuous deployment workflows

Lab Exercise

Create a Feature Branch

git checkout -b feature/my-first-change

Make Changes and Commit

# Edit a file
git add .
git commit -m "feat: add initial change"

Open a Merge Request

Push your branch and create a merge request on the Git server.

git push origin feature/my-first-change

Review and Merge

  • Review the changes in the merge request

  • Approve and merge into the main branch

  • Delete the feature branch after merge

Summary

You have practiced creating branches, committing changes, and merging through a pull/merge request workflow. This branching workflow forms the basis for the CI/CD pipelines you will build on Day 2.