Master the GitFlow branching model for structured development
Learn the GitFlow branching model and how to implement it in your projects.
GitFlow is a branching model that provides a robust framework for managing larger projects. It defines a strict branching model designed around project releases.
- •
Two main branches:
main and develop
- •
Three supporting branches:
feature, release, and hotfix
- •
Strict merge rules:
Define how branches interact
- •
Parallel development
- •
Structured release process
- •
Clear rollback procedures
GitFlow uses two main branches to record the history of the project. The main branch stores the official release history, while the develop branch serves as an integration branch for features.
- •
Contains production-ready code
- •
All commits tagged with version number
- •
Never commit directly to main
- •
Integration branch for features
- •
Contains latest delivered development changes
- •
Source for feature branches
Feature branches are used to develop new features for the upcoming or a distant future release. They exist as long as the feature is in development.
- •
Branch from: develop
- •
Merge back into: develop
- •
Naming: feature/*
- •
One feature per branch
- •
Regular rebases from develop
- •
Clear, descriptive names
Release branches support preparation of a new production release. They allow for minor bug fixes and preparing meta-data for a release.
- •
Branch from: develop
- •
Merge to: main and develop
- •
Naming: release/*
- •
Version number bumping
- •
Bug fixes only - no new features
- •
Documentation updates
Hotfix branches are used to quickly patch production releases. These are similar to release branches but triggered by the need to act immediately upon an undesired state of a live production version.
- •
Branch from: main
- •
Merge to: main and develop
- •
Naming: hotfix/*
- •
Only critical bug fixes
- •
Immediate deployment needed
- •
Version number must be bumped
Here's a quick reference of common GitFlow commands for different operations:
- ✓
Keep main branch stable at all times
- ✓
Tag all releases in main branch
- ✓
Test thoroughly before merging to develop
- ✗
Add new features in release branches
- ✗
Merge without code review
- ✗
Commit directly to main branch
Now that you understand GitFlow, let's explore how to maintain high-quality commits and documentation. In the next lesson, you'll learn about:
- Writing effective commit messages
- Creating atomic commits
- Managing commit history effectively