A simple but effective Git branching strategy inspired by GitHub Flow


π§© 1. main
Branch β Production Ready
"
main
is our stable, production-ready branch. We protect it by blocking direct pushes and only allowing changes through Pull Requests. This ensures only reviewed, tested, and validated code gets deployed."
π± 2. Feature Branches (feature/xyz
)
"When we start a new feature, we create a branch like
feature/user-login
. All development happens there, isolated from the production code. Once the feature is complete, we open a Pull Request tomain
."
π 3. Bugfix Branches (bugfix/abc
)
"Similarly, for bugs, we create
bugfix
branches likebugfix/api-timeout
. These are also merged through PRs after testing."
π 4. Release Branches (release/1.0.0
)
"When preparing for a release, we create a
release
branch. QA teams can test it, and only bugfixes are allowed here. After everything is good, itβs merged intomain
and tagged for deployment."
π 5. Branch Protection & PR Reviews
"We use branch protection rules so that no one can push directly to
main
. Every change must go through a Pull Request, which triggers CI pipelines to run tests, linters, and security checks. At least one reviewer has to approve the PR before it can be merged."
π 6. CI/CD Integration
"CI tools like GitHub Actions run automated tests for every PR. If tests fail, the PR canβt be merged. This keeps our
main
branch clean and always deployable."
π Best Practices Reflected
Practice | Description |
CI/CD | Managed in .github/workflows/ci-cd.yml , triggered on PRs and merges |
IaC | Infra-as-Code split into terraform and ansible directories |
Containerization | Includes Dockerfile and optional docker-compose.yml |
Testing | All test files in src/tests/ run during CI |
Secrets Handling | Use .env.example and GitHub Secrets for secure deployment |
Branching Strategy | Feature/bugfix/release branches merge into main via PRs |
Subscribe to my newsletter
Read articles from Prem Kr Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Prem Kr Gupta
Prem Kr Gupta
A software developer aiming to become a DevOps engineer, exploring and sharing insights on DevOps methodology.