This task involves implementing a Git workflow using the following branches:
feature/*- For new features and bug fixesdev- For integrating and testing featuresrelease/*- For preparing code for productionmain- For stable, production-ready code
This structured workflow helps to organize code changes, improve collaboration, and prepare for CI/CD automation in a DevOps environment.
-
Feature Branches (
feature/*):- Purpose: Used for working on individual features, bug fixes, or any isolated changes.
- Lifecycle:
- Create a feature branch from
dev. - Work on the feature and push changes.
- Open a Pull Request (PR) to merge the feature into
dev.
- Create a feature branch from
-
Development Branch (
dev):- Purpose: The integration branch where all features are merged.
- Lifecycle:
- After each feature is completed, it's merged into
dev. - The
devbranch should always contain code that is ready for testing. - Automated tests should run on this branch (via CI/CD).
- After each feature is completed, it's merged into
-
Release Branches (
release/*):- Purpose: Used for final bug fixes, versioning, and preparing code for production.
- Lifecycle:
- When
devis stable and ready to be deployed, create arelease/*branch. - The release branch undergoes final testing, versioning, and bug fixes.
- Once validated, it's merged into
mainand tagged for production release.
- When
-
Main Branch (
main):- Purpose: Holds stable, production-ready code.
- Lifecycle:
- Only merged into from
release/*branches. - Automatically deployed to production (via CI/CD tools).
- Only merged into from
git init
git checkout -b dev
git checkout -b feature/<feature-name>
git commit -am "Add feature: <feature-name>"
git push -u origin feature/<feature-name>
Go to GitHub, open a Pull Request from feature/ to dev.
git checkout dev
git pull
git checkout -b release/v1.0
git checkout main
git merge release/v1.0
git tag -a v1.0 -m "Release version 1.0"
git push origin main --tags
git checkout dev
git merge release/v1.0