A simple but effective Git branching strategy inspired by GitHub Flow

Prem Kr GuptaPrem Kr Gupta
2 min read

🧩 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 to main."

🐞 3. Bugfix Branches (bugfix/abc)

"Similarly, for bugs, we create bugfix branches like bugfix/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 into main 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

PracticeDescription
CI/CDManaged in .github/workflows/ci-cd.yml, triggered on PRs and merges
IaCInfra-as-Code split into terraform and ansible directories
ContainerizationIncludes Dockerfile and optional docker-compose.yml
TestingAll test files in src/tests/ run during CI
Secrets HandlingUse .env.example and GitHub Secrets for secure deployment
Branching StrategyFeature/bugfix/release branches merge into main via PRs
0
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.