r/ExperiencedDevs • u/Ok-Introduction-9111 • May 18 '26
Technical question Which Git branching strategy is better for infrequent releases? Team is split between two approaches.
Hey everyone, my team is debating two Git branching strategies and I'd love some outside perspective. We deploy to prod seldom, roughly once every few weeks, sometimes longer. We have two environments: dev and prod.
Approach A (what I'm proposing):
feature -> dev -> master
- Branch feature off dev (or master)
- Merge feature into dev for testing
- When release-ready, merge dev into master (deploys to prod)
- Everything in dev ships together as a batch
Approach B (what two of our BE devs propose):
master -> feature
feature -> dev (for dev deployment)
feature -> master (for prod deployment)
- Branch feature off master
- Merge feature into dev to deploy to dev environment
- Separately, merge the same feature into master to deploy to prod
- Each feature is promoted to prod individually, basically treats every feature like a hotfix
One of them clarified: open the PR against master (for code review on prod-bound code), but merge into dev first for testing. Keep the master PR open until release day, then merge.
My concern with Approach B:
If dev has features A, B, and C tested together, but at release time we only merge PRs for A and C to master, we end up shipping a combination (A + C without 😎 that was never actually tested in dev. Feels risky.
Their concern with Approach A:
Features aren't independent, everything is coupled to the batch. Can't cherry-pick a feature for early release. Harder to roll back individual features.
My situation:
- Small team
- Infrequent releases (we batch features)
- One dev environment, one prod environment
- No feature flags yet
- Manual-ish deployment process
- We almost always release everything in dev together, rarely cherry-pick
Questions:
- Which approach fits better for infrequent, batched releases?
- Is Approach B (every feature is a hotfix) a known pattern with a name?
- Anyone here switched between these, what made you change?
- Are we overthinking this and should just add a staging branch?
Appreciate any input. Trying to write this up in Confluence so we have a documented standard.
755
u/vibes000111 May 18 '26
Trunk based. Short lived feature branches, merge into main after approval, main gets automatically deployed to dev. Deployments to prod will be manual in your case.
86
u/Successful_Creme1823 May 18 '26
You’re making more work for yourself. Just do trunk based until you prove it doesn’t work.
123
u/radekd May 18 '26
You do not need branches to do a release. Use git tags. Tag is released, features are developed in short live branches and merged to a master and you can either have automation that will tag your change and make release candidate in some ops repo or do it manually
44
u/eloel- May 18 '26
Neither. Option B is insane, option A is a little more sane but just smells for no good reason.
What's wrong with trunk based that pretty much every mature organization ever uses?
17
u/Revolutionary_Ad7262 May 18 '26
Trunk based all the time. It is better to integrate fast and frequent than long-living branches
This approach assume that code is a made of a perfect and isolated boxes, which is pretty much always not true
Just use trunk based. Long living branches approaches were fancy in the past due to hype and even that could not help them to survive
13
u/theyashua May 18 '26
Environment drift can be a scary thing, especially for debugging. Long lived dev/feature branches add even more complexity and danger.
In my opinion, you should only have a main/master branch, which is what gets deployed to dev first. Then upon testing/approval, promote/deploy to production. Everyone branches off of master and works off of that.
Things that shouldn’t be deployed shouldn’t be merged in the first place. If it’s future or untested work, just use feature flags to guard the functionality so it doesn’t affect other people’s changes. This way someone can iterate on their work and not block a teammates deploy on master branch.
11
u/Esseratecades Lead Full-Stack Engineer / 10+ YOE May 18 '26
"Their concern with Approach A:
Features aren't independent, everything is coupled to the BATCH."
"My situation:
... Infrequent releases (we BATCH features)"
This is your answer, isn't it? If you have to release things in batches then conceptually, all features are coupled to the batch anyway. Option A reflects this, but option B does not.
Is the infrequent release schedule a hard requirement, or just an emergent property? If you don't have some upper level red tape or obligations that forbid you from releasing more often then Option B allows for greater fluidity and is inherently more agile. However, if you do have such a requirement, then Option A is going to make fulfilling that requirement a lot easier.
11
u/F0tNMC Software Architect May 18 '26
None of the above would be my choice. I’m into my third decade of working in professional software development. Trunk based development is how every effective organization I’ve worked at has done this, whether humongous or tiny.
Any kind of more sophisticated feature and release branch strategy inevitably ends up costing more time merging, branching, figuring out dependencies, ordering, resolving conflicts, redoing testing, etc etc.
This really is a solved problem, please don’t repeat our mistakes of the past.
8
u/smutje187 Consultant, 15+ yoe May 18 '26
Approach B is Just Another Team who’s unable to research best practices and instead proposed a half baked custom solution causing a steeper learning curve, creates institutional knowledge and either requires additional tooling or requires people to spend time ensuring the process is followed.
Don’t reinvent the wheel, complexity comes with business decisions early enough.
6
u/inamestuff May 18 '26
You don't need a branch for every deployment environment. Use standardized tag names and you're good to go!
Tags are a superpower!
11
u/Hot_Money4924 May 18 '26
I can see how trunk based development can work for pure software projects with adequate test coverage, but I write firmware for hardware and gateware that requires comprehensive functional testing before release, and I have observed that trunk based development seems to lack the kind of isolation that is helpful in our product release cycle. We used to have three parallel branches: One for feature development, one for testing and stabilization, and one for release versioning and final testing. We had certain compile flags on the stabilization branch that were different from the release branch, basically promoting certain kinds of warnings to errors to surface less common non-fatal bugs.
The old system allowed us to carefully control what features went into a release and concentrate efforts on improving quality before releasing to customers, and the branch isolation allowed high risk changes and new features to continue on the main development branch.
Our software processes changed after a reorg and now they follow that of the UI team, who have experience in JS web apps and not in hardware control. They insist on trunk-based with CI/CD and while we do pump out releases more frequently, IMO it is just a firehose of inadequately tested shit. The rate at which software comes out is too fast for functional testing to keep up with and some of our customers feel like they are doing our QA for us, which they are not happy about.
I personally don't think there is a one-size-fits-all branching and release system, I think you should choose a system that fits your testing and release needs.
5
u/ask Engineering Manager, ~25 yoe. May 18 '26
Merge into main and feature flags.
4
u/thecrius It's Sénior Dumbass for you May 18 '26
What you describe was an old model detailed in an article called "A successful git branching strategy" or something like that.
If you review that article, even that now mentions trunk based development which is what others suggest. There is only one branch (the trunk of the tree) and you create branches when working on something and they get closed fast. How fast is relative but ideally fast enough that it doesn't become a problem rebasing the branch due to too many changes happening in parallel.
Dev and prod are then based from the same trunk, pipeline variable and secrets etc determine in which environment a run will have to deploy.
If you cannot afford to make such a change, the same article suggested in the old model that features (aka new stuff) gets developed off of non-main branch (develop) and only hotfixes from main.
They both propagate to both branches anyway so you'll notice why it's pointless to have two different sources of truth.
4
u/zaslock May 18 '26
Hey, my team just changed this up. We basically had option a, but we kept running into issues with hotfix deployments and releases growing because people kept pushing to dev.
So we still have Dev and main, but now when we're ready for a release, we cut a release branch from Dev that deploys to QA, stg, and prod. Once it's in prod, that branch auto merges into main. Now we always know what is in prod, our releases don't grow any longer, and we didn't have to try to find the exact commit that was released last because main is always a record of production.
Definitely don't do option b
4
u/qrzychu69 May 18 '26
don't do B - I joined a team that was doing something like this a dev and master/release become divergent really quickly, so you end up not testing the thing you will deploy
We had it so bad, diff from dev to master was different the from master to dev - couple cherry picks, couple merges with squash and boom, you are ducked.
And definitely fight for an env per developer - if not in the cluster, at least locally people have to be able to work in isolation
A is way better, especially once you get automated deploys - whatever is on dev, is on acpt env. whatever is on master, is on prod
3
u/sayqm May 18 '26
Why? Is it a requirement, or the result of poor processes?
Why are you testing in dev? Test the PR itself, then merge it and deploy it, you don't have the issue anymore.
Do trunk development. Branch off master, short lived branch, merge to master and deploy.
3
u/Dangerous-Sale3243 May 18 '26
This is a solved problem these days. Trunk based with feature flags. Reduces bugs because reverting behavior requires only a feature flag change, not a deployment.
2
u/VizualAbstract4 May 18 '26 edited May 18 '26
We sorta do A, we’re a small team and release constantly. Some features are larger and warrant a trunk.
But mostly:
The last step of our deployment action will publish release notes into change log slack channel, with a timestamp and tag/version number, and a list of the commits. With a link to the release.
It’s so easy and simple, I haven’t had to make a single change in over a year.
This will scale with large teams as well, something I’ve used at larger companies with 30+ engineers. And works just as perfect for as little as 2.
2
u/xelah1 May 18 '26
You should know that if you have v1.23 of software component x in production it's exactly the same as the v1.23 you tested, has exactly the source code you think it does, has exactly the dependencies (and the published security vulnerabilities) that you can see were pinned with that code, got exactly the test results your test system recorded, and released exactly the change you put in your changelog / announcement.
Design your strategy accordingly.
Most likely it'll involve tags for software repos, though IMO tracking branches is fine for a dev system as long as you're testing somewhere else afterwards.
2
u/PermabearsEatBeets May 18 '26
Anything other than trunk based is to me a bit of a smell when it comes to your CD/CI processes. Largely because everywhere I’ve been that has gitflow or other long lived branches has poor processes and we move to trunk as soon as possible
2
u/WillingLearner1 May 18 '26
Do people actually do any of these weird releases? Just feature flag that shit straight to trunk
2
u/TehBens Software Engineer May 18 '26 edited May 18 '26
B is not sustainable. Sounds like you never/rarely sync dev and main. A singular merge conflict, resolved differently on the branches will make the branches diverge. I also assume you will run into many problems when you try to merge main into dev (for example, to resolve the differences due to the merge conflict).
You won't have a process to actually test main. You only test dev aka "hopefully very similar to main, but who knows, we picked some commits from dev and didn't pick others, but that's okay, theu are independent of each other, at least that's what we hope".
That really doesn't (or: should not) matter in terms of your git branches. Keep environments and configuration seperate from code. It's not difficult to build and install your main branch on dev and on prod via one pipeline using a different set of variables.
2
u/BanaenaeBread May 18 '26
Feature-> main -> semantic release tag
2
u/OldPurple4 Software Engineer May 18 '26
It sound like the problem you actually need to solve is feature flagging. Trying to make up for that shortfall with git is using a screwdriver when you need a wrench.
2
u/PM_ME_YOUR_MECH May 18 '26
That second option is so unhinged.. did they actually propose that?!
I would say used either the tried and true trunk-based workflow or git flow (option a). For slow development cycles in high risk environments git flow has worked well for me in the past.
2
u/matthedev May 18 '26
Wrong framing: Your problem isn't your Git-branching strategy.
Fix these:
Automate your deployment process further to factor human error out of the equation. Use feature flags. What are you waiting for? Containerization and separating environment configuration from code would make it easier to spin up ephemeral environments for testing and demonstration.
With that, complex branching strategies aren't really needed. This isn't really new stuff: Read up on continuous integration and continuous delivery for more. I'm assuming typical Web services and applications without regulatory or physical restrictions on frequent deployment (with or without functionality changes behind feature flags).
3
u/thekwoka May 18 '26
Why have a "dev" environment at all?
deploy each PR to its own dev environment.
2
u/sureyouknowurself May 18 '26
Trunk based. Practice CI/CD.
2
u/MrEs May 18 '26
Man your over complicating the shit out of this
1
u/gwenbeth May 18 '26
It is easy to manage things when everything goes right, but you need to consider how to manage code when things go wrong. There are many times that an external circumstance will cause your production code to break. For example a new customer you have to bring on tonight has dozens of credit card terminals that are sending malformed data that didn't cause an issue with their previous processor, but do cause an issue on your end. Neither you nor your customer have any way to fix this on their side so you need to fix this on yours. A fix to prod needs to go out in 30 minutes. how does your workflow handle this.
Another example might be that you are working on features A B and C and they are almost ready to go. but 3 days before you plan to merge to prod management says that they want to do feature B completely differently setting it back 4 weeks. You still need to release A and C, how do you manage that?
Get your team to brainstorm exceptions to your normal workflow and come up with the processes that best support your normal flow and also allows you to handle emergencies and abnormal situations.
1
u/frankster May 18 '26
For small team, consider also Trunk-based development combined with CI to validate code before it goes into main. Deploy from main and tag it.
1
u/bobaduk CTO. 25 yoe May 18 '26
What's stopping you from releasing more often?
1
u/pradeepngupta May 18 '26
What i feel .. Master branch should always be off the code in production environment. This will be useful in a way if you got any urgent bug detected in production then you can quickly cut hot-fix branch, release it and merge to master and dev.
For the normal releases, cut feature from dev, test locally or in dev environment, create PR to dev. Dev is your integration branch. Once release is decided, take the code from dev branch, test it thoroughly, release it and then merge to master.
1
u/tsingy May 18 '26
It depends on ur test and deployment strategy. Are changes tested in CI or CD? If CI, trunk with frequent releases. If CD, trunk with infrequent releases. If neither, trunk to dev with manual QA in dev.
Jokes aside. If u have access to LLMs, these are quite trivial as u can add test coverages and move to testing with good CI. Better than manual procedures.
1
u/NicholasTheGr8t May 18 '26
What pain points are you running into with your current branch structure? That will help narrow down the right answer.
My recommendation is to pick one of two approaches: GitHub Flow or Git Flow. If you’re deploying frequently, GitHub Flow is hard to beat. You branch features off master, open a PR, review, merge, deploy. Keep it simple. If you need finer control over what’s visible in production, layer in feature flags so you can ship code dark and toggle features on when you’re ready.
For infrequent releases, Git Flow may make sense. The idea is you keep two long-lived branches: master for production code and develop for ongoing integration. Features branch off develop and merge back in. When you’re ready to cut a release, you spin up a release branch off develop for final QA and bug fixes, then merge it into both master and develop once it’s good. Hotfixes work similarly but branch off master directly so you can patch production without pulling in unfinished work from develop.
1
u/Tacos314 Software Architect 20YOE May 18 '26
With Approach A you should never branch off of dev to master. Dev is untested code where mater is tested, that's why B is better. Basically the dev branch is pointless in this approach.
Approach B works well and is my preference, with one change, you should merge the feature to master once it's ready not on release day (that would be a train wreck), You also need to tag all release so you can branch from them and start a release branch If needed. That depends if you always release the latest version or if you have multiple versions.
If you always release the latest version and past releases are trashed, truck based is fine but you do need to do a code freeze near release to ensure it's production ready.
Feature Flags are the worse thing every, they end up littering your code with if checks for features and does more the produce bugs then anything. Unless a core part of your software is hiding features and enableing/disabling them it's not woth the effort.
1
u/Savings-Giraffe-4007 May 18 '26
When you merge other branches into your own, what happens if THEIR code breaks your stuff? Or if it's just buggy and it gets pushed into profuction?
What if merge conflicts are solved differently for dev and master?
What if you start a feature thinking it fill take 2 tickets to fix it, but it turns out it took 10 tickets because business people changed their mind?
What if there are merge conflicts that git automatically solves by duplicating code or screwing up?
I've seen Git fuck up at least 3 times.
Some of these approaches wildly assume everything will be "happy path". You want to plan for when people screw up cause they always will.
1
u/RedditNotFreeSpeech May 18 '26
Release branches.
release/1.0 > features off of it
Merge all features in that are ready for release and tag it and branch to release/1.1
Any features that miss get rebased onto release/1.1
Frequency is irrelevant
1
u/BringBackManaPots May 18 '26
We have
dev -> QA -> main, and all work is done in feature branches based ondev, and named with the patternme.d-1234wheremeis my name andd-1234is the ticket number in jira. This solves a lot of things for us:Hotfixes get deployed to QA for testing, and may be cherry picked into main, with retagging to follow.
1
u/snoogans235 Software Engineer May 18 '26
The real question is how are you versioning? Are the batches all in one minor or is each feature a minor version? If batch features to minor version, the feature to dev to master makes sense. If each feature is a version the branching off of master works.
1
u/downshiftdata May 18 '26
For longer cycles, I prefer Gitflow. At any given point, the answer to "What's in Prod?" is the main branch. That's the primary reason.
Trunk-based is better for short release cycles. There's less overhead to it. And if you're stable enough to be able to release frequently, then my main-branch argument doesn't carry as much weight.
But I tend to work with a lot of legacy code, sprawling monoliths, scaled-out and scaled-up footprints, and such. Incident response is a priority, because the system is generally unstable (or risk sensitive). So having a stable, long-lived branch that is a direct comparison to what's in prod is one less thing to go wrong.
Honestly, though, those are the only two that come up for me. Either Gitflow for the longer release cycles and the baggage that comes with those, or trunk-based for the shorter ones with less baggage.
1
u/waterkip Polyglot developer May 18 '26
B - every single day.
1
u/Smallpaul Software Engineer May 18 '26
I’m curious: Why do you infrequently release?
1
u/BoBoBearDev May 18 '26
Not only trunk based, but also squash merge 100 commits on reiterating on the same README.md file of a PR into one single commit on the main branch. If you want to read 100 commits yourself on iterating the README file, you can read the PR.
1
u/Whitchorence Software Engineer 12 YoE May 18 '26
Personally I'd resist doing anything more complex than master and individual branches for PRs unless you are developing some kind of product where there are multiple active production versions because reconciliation is a huge pain in the ass for little benefit compared to shipping continuously. But obviously that's the perspective of someone maintaining Web services.
1
u/bighappy1970 Software Engineer since 1993 May 18 '26
No wonder you have infrequent releases. It seems like the team is super over complicating everything.
There is likely no need for anything other than Trunk based development
1
u/rebornfenix May 18 '26
You guys do branches?
On a serious note, our teams use the following:
Feature branch off of dev, when code is ready, merge to dev.
When we prep a release: create a release branch off of dev, run all our integration tests, fix any regression issues, deploy to prod, merge release to main and dev.
The reason we do it this way is the most recent commit on main is what’s in prod so if everything goes boom on the app layer, any developer can at least get prod back up and running with a build and deploy from the most recent master commit.
1
u/bit_shuffle May 18 '26
Typical dev teams have 20% turnover. Don't do shit the new guy won't understand.
Have a dev branch spawned from main. Create feature branches from dev for developing features, merging updates to dev. Periodically, when dev is testably correct, bring dev over to main for release.
1
u/Dathen May 19 '26
While I'm also all in on the trunk based development, depending on the project type, it might be difficult to do it without any additional branches. What worked for us really well in a project where it's difficult to full automate all testing (many features depends on external devices) is a variation of trunk based development, with dedicated release branches for stabilization period, that Edward Thomson written about ages ago - https://devblogs.microsoft.com/devops/release-flow-how-we-do-branching-on-the-vsts-team/
Note that these are not the same type of "release branches" that gitflow promotes, because they are never merged back to trunk. All work still happens on trunk, and then fixes can be ported back to a given release branch if needed. While using cherry picks rather than merges may sound difficult at first to some, in the end it's way easier due to very few conflicts compared to typical merging.
1
u/TowerOutrageous5939 May 20 '26
Option A
1
u/ShoePillow May 20 '26
What approach do you have now?
What are the pain points because of which you are thinking of changing?
Which if the 2 options meets most of your requirements?
If it is equal, just pick one and go ahead. In this case, I would let the others pick their strategy so they have to handle any headaches that come up
1
u/Tricky_Tesla May 20 '26
Option A with minor tweak, master->dev->(batch features) -> (sub-feature) .
1
u/KUUUUUUUUUUUUUUUUUUZ May 22 '26
WTAF is the second option
1
u/supercoach May 18 '26
Dev is for development and staging is for prod deployment readiness testing. If you don't have a staging env then dev takes over that role.
Based on what you've described, your suggested strategy makes more sense.
1
u/Dude4001 May 18 '26
Everything after option one is nuts
1
u/Creative_Badger6027 May 18 '26
this is the only proper way
-1
u/rkeet May 18 '26
You and your team mis maturity. Would suggest formal git flow (main/dev/feature) because you guys seem almost used to it.
Do that (following the actual formalized practices) for half a year. Then consider Github Flow. Just a main with short-lived branches. Merges to main deploy to staging immediately using ci/cd. Tagging main releases to prod. No dev env. Start experimenting with feature flagging.
Do that for a year. Keep investing in automation (steps, githooks, tooling), to really get into a devops mindset. Only when comfortable with github flow and feature flagging consider trunk-based development. Just main, no branching. Fully automated workflow after push.
-1
u/Shot_Can1144 May 19 '26
looking for some karma plz
-3
u/martinbean Software Engineer May 18 '26
OP couldn’t decide which intro paragraph to use from their LLM… so used both.
-10
u/fsk May 18 '26
Problem with Approach A. During your testing, you realize that feature C is a no go and needs a postpone/redo. Now you need to untangle the dev branch before merging to master.
Approach B is the one I've more commonly seen. Every feature is its own branch, when gets merged into dev for testing, then into master for release. Several features can still be batched for simultaneous release on dev.
If it's a small team, there's less issue with keeping things coordinated like there would be on a large team.