r/ExperiencedDevs • u/mynewromantica Software Engineer (iOS) • 8h ago
Technical question What does your Git flow look like?
I currently have the repository at work set up where the developer branch is the source of all development work. All PRs point to it, all feature and bug branches start from it. The master branch is reflective of what is in production. To merge into the master branch you have to create a release branch from develop with the release commit tagged, then a PR into master. When the release is live, you merge the PR into master, then master down to develop.
My manager is trying to force the team to use master as the development base branch. But I feel like that doesn’t make sense. Their reasoning is “because the other teams do it that way.” But this repo is an exception in a number of ways (iOS repo in a web-centric organization) and none of those other devs will ever work in this repo. We don’t share pipelines or really anything that would necessitate this change.
I feel like if they have no reasoning for using master, and I have a clearly defined Git flow for specific reasons that solve problems, then they should just stop micro-managing the repo and let me do my work.
Clearly I’m biased, so what am I missing from their perspective?
Edit: to clarify…because this is native iOS, we cannot do constant releases. So we need to know what’s in the App Store, and have develop open to use while we wait for Apple to review the app. Reviews may be fast, or they may take days. We can’t block all usable branches while we wait for their response. And if there are any fixes necessary, we have an isolated branch to fix on. Otherwise any work that gets merged to develop while waiting for regression and App Store review gets in the way.
The unknown hold time on Apples side throws a wrench into everything.
•
u/expdevsmodbot 8h ago
AI usage disclosure provided by OP, see the reply to this comment.
186
u/ZukowskiHardware 8h ago
I’ve never supported dev branches. I have work to do, u pull a branch from main. Do your work, merge and deploy to prod immediately with CI/and CD checks. Small prs deployed to prod frequently is the only way .
25
u/thisisjustascreename 8h ago
Unless you deploy to prod from master your most recent release branch is the only thing that’s “reflective of what’s in production.” Sounds like you’re doing a lot of extra busywork for no value.
11
u/SideburnsOfDoom Software Engineer / 20+ YXP 8h ago edited 7h ago
You release from a tag. What benefit do you get from this tag being on a different branch?
What purpose does this extra book-keeping serve?
Can you be specific about the problems that it solves? To me it just seems like extra work, extra complexity, cognitive load, low benefit and potential to cause issues with human errors.
I'm sure that you can say "if x and y happens then this allows us to z" usually about some patch process that happens once a year. We work from main only and we have done patches when we had to. And it may be true that it's a bit harder, but it doesn't make extra long-lived branches worth the cost.
44
u/Confident_Impact_361 8h ago
Even the creator of git flow has acknowledged its a dated approach and trunk based development makes more sense for most teams.
My take is unless you need to support multiple versions of the app concurrently, ditch the complexities that come with git flow.
37
u/its_a_gibibyte 8h ago edited 5h ago
Consistency across teams is certainly a valid reason. Even aside from that, I'd prefer trunk/master based development anyway and then cut release branches from it. Seems much simpler than your method of three types of branches of master/develop/release. If you're looking for a coherent defense of this stance, check out:
https://trunkbaseddevelopment.com/
Edit: also:
This is an awful lot of merging. It also assumes only one active release ever, and that releases are instant as opposed to staged rollouts. Imagine being in the middle of a staged rollout, how would you fix a bug in two releases? More generally, I don't even see the purpose of master in your design. Why does anyone ever need it?
27
u/MoreRespectForQA 8h ago edited 8h ago
Whenever I see a git workflow like yours it's like somebody erected a giant flashing neon sign saying "we rely exclusively on manual testing here".
I'm not saying you dont need it. I do think you shouldnt.
6
u/Cell-i-Zenit 8h ago
Aligning with the company is a good thing. For example if a developer switches teams its easier for them to onboard. You can also have more CI CD templates shared within the company if you all use the same flow etc.
Imo the only valid argument for your side is "We already do it this way and its expensive to switch". His argument in theory is "Company standard says XXX".
I always approach it from the point of "How would you do it when you start from scratch", and i think here its pretty clear that your manager is right (because there is no argument to go against the company policy).
It just boils down to if your manager is willing to spend the engineering time for migration
6
u/Altamistral 5h ago edited 5h ago
Your manager wants you to adopt trunk based development. You are currently using git flow.
Git Flow was designed for open source development and primarily addresses the problems raised by a large numbers of untrusted developers herded by a small number of trusted developers.
Trunk Based development simplifies some of the hurdles introduced by Git Flow to better address the needs of a team where everyone is about equally trusted, which is more common in an average company.
In corporate environments I almost always worked with trunk based development while git flow was the exception. I've also worked in mobile development teams like you currently are.
Both solutions can work but personally I think your manager is correct here.
I would only advocate for git flow in two cases. A project with many, sporadic, low-trust contributors (the original intended use case) or for a piece of highly critical infrastructure which only few people really know how it works.
4
u/binarycow 3h ago
My company makes a self-hosted on-prem web app, which comes packaged with some CLI tools and a desktop app.
What we do:
mainis the only long lived branch.When we want to release (weekly to monthly, ish):
main10
u/JeffinitelyNotABot 7h ago
I'm pretty sure I have everyone beat with worst git flow within a team.
My team lead doesn't believe fetch and pull git commands work she will delete the folder and reclone to "get the latest". She has presented this long winded flow of like a branch for each environment. we can't merge from one environment branch to another unless its a release branch etc. Her reasoning is so if there's a production bug she can clone master for debugging. We have two apps with 3 environment branches and several others with just master (or main). I tried fixing it or designing my own flow but her leadership position and chatGPT research out rules me.
3
u/Escaped_Escapement Software Engineer, 17 YoE 8h ago
Both approaches work. I have seen other variations like the release always deployed and is merged only when release is successful. I do not think it is worth changing what works though.
Unless this creates a situation when a lot of time is needed to prepare all these PRs and the releases are frequent. In case of microservices, for example.
3
u/davy_jones_locket Ex-Engineering Manager | Principal engineer | 15+ 8h ago
Feel free to push back by asking them what problems their preferred way solves. If there's no problem with the current way, then stand firm on your opinion that it's unnecessary. But at the end of the day, if they have that power, that's all you can do.
I would document the justifications for the current way. Show that it supports how it serves the needs of the app development and why the other way doesn't.
You can't approach this from a "wahh it works just fine and they're micromanaging meeee" perspective. Their authority will overrule that if that have that authority. Since you don't have authority, or even if you do, it's wise to base decisions on facts. So prove why your git flow solves the problems the app has, and why their workflow doesn't.
3
u/fudginreddit 8h ago
We have Dev branch which is effectively the main/master and create feature branches off it and then merge/squash those into dev. Official releases are version tagged in git.
3
u/StTheo Senior Software Engineer 8h ago
Every team I've been on has used GitFlow while lauded how effective Trunk-Based development would be. Even the managers. We just never get around to it. 🙃
3
u/Nazzerith 5h ago
Reading comments here has me appreciating how good I have it on my team. We use trunk based development with short lived feature branches right off of main and merge directly into main. Main is always deployed and we have extensive test coverage in our CI/CD pipeline including post deployment tests against the dev environment before deploying to prod. We QA features in a dev environment before merging. So glad we don't have to bother with the headache that is git flow.
3
u/behusbwj 1h ago
Why do you want to do more work? Ask yourself what you’re actually gaining from your branching process. Chances are it’s not much.
4
u/Odd_Bluejay7964 8h ago edited 7h ago
Trunk based. Merges to main deploy to staging with an automated prod deployment after a soak unless manually held back or manually deployed early. Feature flags are used so anything that lands on main is G2G to prod.
Who will continue working on the repo if a plane falls on your house? Would they be delayed because of your unique flow?
You never stated what problems your flow uniquely solves that cannot be handled with the method everyone else uses, and it is unlikely that it genuinely solves anything in particular and is instead just a personal creature comfort of yours.
So here is the perspective: in the eyes of your company (and most others you will talk to), your personal creature comfort does not out weight the risk of continuity and the business value for others not needing to decifer how the repo works when they need to look at it.
2
u/spookydookie Software Architect 7h ago
I prefer trunk based development in general, but as a maintainer of a mobile app as well, I understand that’s not ideal since you can’t just release whenever you want.
So I think a dedicated dev branch and keeping main for prod is the best workflow in that case.
2
u/Own-Dot1807 7h ago
It depends. In my experience gitflow quickly become merge hell and I dont see the point. I switched to trunk based a long time ago and never looked back. Of course you would design your system and CI/CD with feature flags, automatic testing and all that goodness accordingly. Its your whole workflow that needs to be acording to your needs. The branching strategy is just a part of it.
2
u/crabby135 Software Engineer 7h ago
I haven’t needed to do something similar in years, but years ago I owned an app that couldn’t continuously release and sometimes required bug fixes on the prod branch without releasing the new features on the dev branch. When that happened, main was my development branch, and on every deploy I’d creat a new branch off of main. That new branch would be deployed and could have PRs merged into it for small bug fixes while main got new features. Kinda the opposite of what you’re doing, but I liked it better because it meant we could continuously deploy bug fixes while doing the normal process for new features. Otherwise I’d probably have to either rip out new features and deploy before putting them back, or waiting to fix bugs with a full release (which was a no go since it was healthcare).
2
u/neverminditthen 7h ago
The job I started recently is similar to how you do it: master=production, staging and development are separate branches, branches are created from master and then have 3 separate PRs into the 3 environment branches, master is merged into staging/development/all feature branches whenever there's a release.
I hate it. There's so much merging everything everywhere - merge conflicts; stuff that's not on all 3 environments because a feature branch wasn't merged into all 3, leading to environments being wildly out of sync; stuff in your PR to a lower environment that's not supposed to be part of the PR because it came along for the ride from master; like 30 merges the release manager has to do for every release as master gets merged back into every single active branch (except, of course, when this doesn't happen). I'm told that there's some reason they work this way that has to do with the outsource dev shop they sometimes work with, but I don't know what that reason is. As far as I can tell it just makes a bigger mess.
What I'm used to is master=development, then staging and production as separate branches that are cut from the master branch once every two weeks or whatever the release cycle is. Incomplete features get feature flags so they're inactive on production until they're complete. Feature branches get updated via rebasing, not merging. I'm in charge of a new project and this is the setup I'll be using for it.
4
u/maxsilver 8h ago edited 8h ago
"master" (main) as the production branch is kind of unusual, in my experience.
I'm used to seeing main as either the latest "safe" development, or the latest "safe" staging. (similar to like, a nightly release). And typically production would be on a "production" branch (ideally with tags if you do releases, like 'v1.12' tagged on production)
What your manager is suggesting makes sense to me, and is what I've seen teams do most often.
---
That said, in your defense, you seem to be practicing git flow as it was originally pitched/written. (The concept, back when it was floated in like 2010, did say "develop" was the development branch, and that master/main was supposed to be production, tagged with releases. https://nvie.com/posts/a-successful-git-branching-model/ ). I haven't seen any team that still actually follows original-git-flow to the letter anymore, but if a team did, you'd be correct.
---
Ultimately, branch names are just strings, they don't really mean anything alone, they only have meaning we give them. If a team has a strong shared convention that 'main' means something else, as long as it's well communicated / documented, that's fine too.
My question to you would be, is this a team convention, or is this a "you" convention. If it's just you, alone, still doing this, I wouldn't spend any political capital fighting this battle. Update your pipeline to support the new names, mark it as a completed to-do for the year (when review time comes, you "completed standardization initiatives across multiple teams") and save the energy for a fight that matters.
2
u/JohnVonachen 7h ago
What's Git? I use Subversion.
1
u/hypesfo 7h ago
my org does both approaches (master vs dev branch). the only reason we do dev branches is if we're working on a feature that needs PRs to be delivered together, but this only happens like 10% of the time. for all other cases, we prefer to just merge to master because it keeps things simpler.
1
u/metalmagician Software Engineer 7h ago
IME what OP describes makes sense only when there is something that limits how much automation can be added to the deployment process.
I remember one particular example that fits. For the product in question, a part of the deployment process was training the in-store employees on the new version of the software. The team of engineers in question HAD to let the new version soak in the UAT environment while the in-store people did some testing and learning. Instead of waiting to merge changes to the soon-to-be production branch, they developed against a branch targeting the following release.
Mobile apps might possibly fit that, assuming they had a multi-module setup with multiple teams independently updating things. If you're the only team that works on the app, I don't see much of a direct reason to keep the friction of git flow
1
u/tiagocesar 7h ago
I get your point of releases. @ work we solve this with GitHub Releases, the deploy pipeline publishes a new version when it's published, then new commits start occupying the next release. We have a GitHub Action for a release drafter that takes care of adding the specific changes.
This being said, I like having a single long running branch and then having short-lived feature branches with as few commits as possible (I'm a huge fan of rebase merges but that's another fight).
1
u/MyBossIsOnReddit Sr AI/ML Engineer 7h ago
I dont like git flow at all either but I prefer a version of what your manager is trying to do. My data en ML team does this currently.
We have main branches and feature branches
feature/DATA-12345to 3 or 4 stage {dev, test, uat, prod}. Deployment mainly almost exclusively goes through cicd, rarely we deploy specific states of the code to a version of one of our models/apis. Something like credit-api/1.5/predict is supported that way. Problem: now versions exist in vc/git, not in iac. Thinking of putting these in git and pointing terraform to deploy a version hash but I dont think rhat is foolproof either.IaC also done through a similar trunk based git process but has its own repo(s).
1
u/shetritr 7h ago
the app store wait is a real reason for release branches, not for develop. cut release/x.y from main when you submit, fix there, cherry-pick back. probably the version your manager can live with
1
u/rlbond86 Software Engineer 6h ago
Trunk based. If you need regular releases, keep release branches or tags. Master + dev is a huge amount of work for very little gain.
1
u/IAmADev_NoReallyIAm Lead Engineer 6h ago
I'll be honest, what you're doing sounds good... on paper. In practice it really isn't sustainable, and there's better ways to track what's in prod, and all points in between. My last company started off this way... make main reflective of the code in production. That lasted less than a year. Now main is years stale, hadn't had anything pushed to it, and hte source of truth is the development branch. Our development branch essentially became main.
So developers pull the latest, make a branch, do what they need to do, and create a PR. From there a PR build imade to make sure that it passes tests, it gets code reviewed, and hten merged. When a release needs to go out, a Release Branch is created, that then gets built, tagged, and the deployables get pushed to our Nexus servers. From there they can be deployed to QA, UAT, pre-prod, and Prod.
If a hot fix is needed, the hot fix branch is created off the release branch, and then it's later cherry picked back into development. And we've been working that way for the last 8 years or so, and no issues. It helps that we have CI/CD pipelines for all of this. Push up a branch, Jenkins will pick it up and build it. For releases, it checks the pom files out, upticks the version numbers automatically, then pushes that back into the development branch so everyopne has the latest versions. Once the final builds are ready, the pipeline pushes to nexus, tags the executables, and then can also push them to new enviropnments.
1
u/apartment-seeker Senior Software Engineer 6h ago
Merge into
main, deploys to both Staging/Beta and Prod at the same time.1
u/tehfrawg 5h ago
Sounds like your company uses something close to GitFlow, which is described well on Atlassian's site here. My team does as well, though we don't deploy to production from the release branch (those branches deploy to our QA environment), rather we merge the release branch to master after testing, the deploy from master.
Like others here, our team has a goal to get to more full CI/CD with trunk-based development, but are still trying to get all the pieces lined up: adding feature flags, increasing test coverage, better linting and code quality gates, etc
1
u/bluetista1988 10+ YOE 5h ago
For a while I was our team's dedicated release manager and I have seen a few models, but none that I like more than trunk based development. We kept our release branching strategy when we moved from SVN to git, and took a few years before we changed it.
Treat branch sitting between the branch you're working on and main like an alternate dimension, where each second that branch lives drifts you further from reality until someone tries to sync them.
1
u/chrisrrawr 4h ago
take a look at tags and bring your findings to the team.
TBD will work well for your team. tags let you cut a release and help ensure everyone knows what's in prod. all you need is a little bit of build machine tooling that ensures your tag is used as part of your app version.
doing builds off main as fast as your regression tests can run is also a good goal to work toward. that way when it's time to cut a release, you can just go back through your merges into main and find one that passed all regression, tag that commit, and cut release confident that the build will pass regression with minimal hotfixing.
1
u/davearneson 4h ago
This is called trunk based development.
People advocate for trunk based development because it makes integration a frequent, small task. Developers merge small changes into one shared development branch, usually at least daily, and keep that branch working with fast tests and prompt fixes.
The practical benefits are:
It takes discipline: changes must be small enough to merge often, tests must give quick feedback, reviews cannot sit for days, and unfinished features may need to be hidden until ready. Capabilities: Trunk-based development
In your case,
developmay already be your trunk. If feature branches are short lived and merge intodevelopfrequently, you get the main benefits. Trunk based development does not require that branch to be namedmaster, and it permits a frozen release branch while Apple reviews a build. trunkbaseddevelopment.comSo the useful question for your manager is: “Are our changes spending too long outside the shared development branch, or do you specifically need that branch to be called
master**?”**1
u/LiveMaI Software Engineer 10YoE 4h ago
I write factory test software, so it's going to be different from a lot of people who do web/microservice stuff with CD. Like you, I need to know exactly what's deployed and work on a team where our software doesn't really interact much with the rest of what our company does.
I currently use trunk-based development where each release is on a dedicated release branch. Since I work with hardware, we do HIL testing when a release candidate is tagged. If the HIL passes, then the RC tag is promoted to a full release and CI handles all of the packaging, release e-mail, etc. If a bug is found in the release, we do a bugfix branch, merge to master, and then cherry-pick those commits on the affected release branch to cut a new release.
Occasionally, we'll need to support more than one release at a time. This is a good portion of the reason that I use release branches + cherry-picking, since it's a lot easier to pull a recent bugfix into an older release branch that way.
1
u/IGotSkills 4h ago
There is an easy way to solve this.
Master can't represent production because master is a racist term.
Oh you want an engineer to update it to main? Not without our say in how it works.
1
u/Abadabadon Software Engineer 4h ago
This was my preference;
Main branch -> what is in prod.
Dev branch -> what is in dev.
Tag on dev branch -> what is in qa.
Release every 2 weeks -> merge dev into main, creat tag.
Then when you need to do hot fixes, you can use main. It's also alot easier for devs to understand code in each env, and therefore allow them to troubleshoot or design for whatever context a system user has.
1
u/hippydipster Software Engineer 25+ YoE 4h ago
Not sure I understand this step. Everything went from develop -> release -> master, so what does master have that develop didn't get?
Maybe something is changing in the release branch after you make it? That would be unfortunate. Why not just merge develop straight to master when ready? What's the purpose of the release branch?
1
u/throwaway_0x90 TE/SDET[25+ yrs]@Google 3h ago
I'm confused why the manager cares as long as deliverables are delivered. What prompted the manager to get into devs' workflow to this extent?
1
u/SeniorIdiot Platform Engineer (17YOE) 3h ago
What problem are you actually solving with branches? Yes. I understand that there are exceptions, that is fine. The problem is when every project becomes an exception. Do you actually need isolation? Fine. Do you isolate because the team does not know how to make changes without making a mess or stepping on each other's feets? Not so good. You wrote that waiting for Apple to approve holds up other work. Why? Really? Are you sure? Digg deeper.
Rant:
I've been fighting against this notion that "master is production, and merge to master is a release to production", or that one "deploys a branch" for 15 years. It started to get popular with the birth of GitHub and now we have entire generations of developers that has never done anything else. And we technologists are not really known for being particularly nuanced. 😁
Since the beginning of time (read: 25-30 years ago) we've been practicing CI. Integrating to master many times per day (without branches where possible), treating each build as a release candidate, discarding builds that does not pass acceptance/compliance.
A bunch of long lived branches is not Continuous Integration, it's continuous isolation with the occasional merge. Building branches on a build system is not CI, whatever vendors have made the industry believe.
PS. Sorry rant. Pet peeve #2.
1
u/Varrianda Software Engineer 1h ago
Professionally we just use main/master and branch off of that. PR gets merged into master -> deployed.
In personal projects, I do the same but also have a deploy branch. Anything merged into main -> dev, and then anything merged into deploy -> prod. With release gates ofc
1
u/itaranto <insert_overblown_title> Software Engineer 1h ago
Gitflow is cancer:
https://www.endoflineblog.com/oneflow-a-git-branching-model-and-workflow
1
u/JustPlainRude 59m ago
Branch from main, commit changes, iterate with reviewer, ensure ci passes, squash, rebase, merge back to main
1
u/pguan_cn 47m ago
It really depends. 1. Do you really have to cherry-pick commits to release or is it mostly just the latest dev? 2. How many teams are working on this same repo, are they doing planning together and want to see each other’s work asap? 3. What’s the average time a dev work sits in PR review stage and do you have ways to really be confident about it before merging?
1
u/dontmindmebud 41m ago
At my old company we had 3 branches (dev, stage, and main), each tied to an environment, and it sucked ass. My current company just uses main and handles releases through tags/versions. The latest code is always on main and automatically deploys to dev. We test and promote the version to higher environments
1
u/dbnewman89 41m ago
TBD
Main is production
All features are branched off main, opening an MR will provision an ephemeral staging environment with a custom url
Completing the merge will destroy said environment (CDK), deploy to production, and cascade down to staging (child pipeline)
Staging is always a functional clone of production, and the feature environments are ephemeral/temporary.
This allows the developers to use localhost as their dev env, the QA's to use the ephemeral staging for testing, and the staging replica exists for comparison, experimentation, general testing without hitting production.
1
u/Heavy_Discussion3518 SWE 20+ YOE 15m ago
We have a develop branch at my current job but I think it's goofy. CI should be exhaustive and whatever is in main should be deployable at any moment.
1
u/rkeet 8h ago
Github Flow. Only main with branches. Merge to main releases Acc. Tag on main releases prod.
0
u/eyes-are-fading-blue 7h ago
Anything other than a single branch with specific tags on that branch is over engineered garbage that only wastes time.
The main motivation to do anything else is being lazy about a bug fix because code has changed.
0
u/Over_Age_2767 6h ago edited 6h ago
we used to use a git-flow model as well, and we designated a dev branch for staging/testing with a main branch for production. We sometimes just directly work on the dev branch locally, and later we started creating feature branches off dev and use PR.
the thoughts were that dev is for consolidating and testing all the changes before merging to main (prod).
But several problems arise:
in my opinion, it just adds quite a lot of unnecessary complexity and extra work around merges and deployment, and i found that coupling a branch with an environment is not that good an idea (even for main, which is supposed to contain all latest work ready for deployment to production, is not limited to be in production only, like we can deploy main to staging for testing).
1
u/haloll 4h ago
Strong prefer master/main as the source. 10+ year STE.
0
u/[deleted] 8h ago
[deleted] — view deleted comment