Day 10 | Git Branching Strategy
Here is an explanation of common Git branching strategies, considering an organization that uses a main or master branch as the primary development branch:
Main (or Master) Branch:
The main branch represents the primary line of development.
All stable and production-ready code should reside in this branch.
Developers create feature branches or topic branches based on the main branch.
Feature Branches:
Feature branches are created by developers to work on new features or fixes.
These branches branch off from the main branch.
Developers work independently on their features and merge them back into the main branch when complete.
Example: Creating a feature branch named "feature/login."
Develop Branch:
Sometimes, a separate "develop" branch is used to integrate and test features.
Feature branches are merged into the development branch.
This allows the testing of multiple features together.
The development branch should be stable but not necessarily production-ready.
Release Branch:
A release branch is created when the development team is preparing for a new release.
It's a snapshot of the development branch, indicating features for the upcoming release.
No new features are added to the release branch; only bug fixes and adjustments are made.
This branch is thoroughly tested before merging into the main branch.
Example: Creating a release branch named "release/1.0."
Hotfix Branches:
Hotfix branches are created to fix critical issues in the production code.
These branches are based on the main branch.
Once the fix is complete, the changes are merged into both the main branch and the development branch.
Example: Creating a hotfix branch named "hotfix/bug123."
Support Branches:
In some cases, long-term support (LTS) versions are maintained.
Support branches are used to manage updates and fixes for these versions.
They branch off from the main branch and are kept separate from the current development.
Example: Creating a support branch named "support/1.x."
Merging:
Feature branches are merged into the development branch when features are ready.
The release branch is merged into the main branch when the release is ready.
Hotfix branches are merged into both the main and developed branches.
Support branches receive updates, and those updates are merged into the main branch.
Versioning:
- Each release and support branch may have a version number (e.g., 1.0, 1.1) to track software versions.
Example: Suppose you're working on a project. You start by creating a feature branch, "feature/login," based on the main branch. After implementing the login feature, you create a pull request to merge it into the development branch. When it's tested and ready for release, you create a "release/1.0" branch from the development branch. This branch is used for final testing and bug fixes. Once it's stable, it's merged into the main branch, marking the release of version 1.0. (In some cases once the release branch is merged with the main branch, the release branch will be deleted probably).
This branching strategy helps organize development, ensure code stability, and facilitate collaboration in larger organizations.
Subscribe to my newsletter
Read articles from Sarat Motamarri directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Sarat Motamarri
Sarat Motamarri
Hey there, I'm Sarat Motamarri, an aspiring engineer mastering the art of DevOps & AWS. If you're as passionate about the cloud and open-source wizardry as I am, you're in the right place! Let's explore the skies together ๐๐ฎ #CloudEnthusiast #DevOpsDreamer"