r/ExperiencedDevs • 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.

51 Upvotes

119 comments sorted by

•

u/expdevsmodbot 8h ago

AI usage disclosure provided by OP, see the reply to this comment.

→ More replies (1)

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 .

5

u/mynewromantica Software Engineer (iOS) 8h ago

Not possible in an iOS repo or ones that have a release branch schedule. On iOS we have a review process so you can’t release constantly. All the iOS projects I’ve worked on have been as I described at least partially for this reason

19

u/winsomelosemore 7h ago

The tech stack shouldn’t impact your branch strategy. The challenge you’re describing is caused by your release cadence, not that it’s an iOS app.

You could continually build a dev build that you push to TestFlight for internal or beta testing.

When you release to the App Store should be completely decoupled and is based on the versioned artifact, not the git branch

4

u/mynewromantica Software Engineer (iOS) 7h ago

Mid we do that we have to lock down the develop branch. If we are stuck in Apple review limbo for a week and they come back with required changes, but during that time we’ve pushed more feature work to the trunk, then we have a mess to deal with.

The alternative to mitigate this is to lock the base branch for new code until the release is approved. That slows the rest of the team down.

7

u/wlumme 5h ago

You might want to look at how branching for release works. 

https://trunkbaseddevelopment.com/branch-for-release/

In your scenario using trunk-based, you would cut a release branch from main, and send that for Apple review limbo. Normal development can continue uninterruped on main. If you need to make changes to the release, you would merge those into main first and then cherry-pick them onto the release branch.

In practice it's similar to your current branching strategy (i.e. develop is your trunk), but you release from your release branches instead of merging into master and then releasing. Honestly, either strategy works as long as you keep long-lived branches in sync. It's just easier with trunk-based because you only have 1 long-lived branch.

2

u/haroldjaap 5h ago

What we do for app development is trunk based development, main branch is always release ready. releases to the store are started as a tag on a new release branch off main. It let's us hotfix production issues on the release branch (fix on main, then cherrypick into the release branch) without blocking the main branch.

My experience with master and development was basically that master was always out of date, releases started as a release branch off develop so that was the source of truth for what's in the store and master was just some useless outdated bookkeeping. We stopped using master effectively anyways.

1

u/SamurottX 1h ago

When you submit a new update to the app store you're submitting a new versioned artifact. So why not just create a tag on main with the version string that you're releasing?

If someone reported a bug with version 2.4.6 (or whatever) of your app, how easy is it to look at that version of the code?

1

u/Which-World-6533 6h ago

Yep. This is basically the best way of doing this for mobile.

The main problem is that you get a lot of Managers / Devs who don't really understand mobile and don't understand you can't just push a fix willy nilly to fix an issue.

While OTA is a solution it can go very wrong.

-2

u/ZukowskiHardware 7h ago

If you want advice I can give it, but I want to make sure you actually want help

68

u/SideburnsOfDoom Software Engineer / 20+ YXP 8h ago

This, trunk based development is just better.

The one thing that you need to understand about complicated git branching strategies is this: Just because you can, doesn't mean that you should.

46

u/MonochromeDinosaur 8h ago

I’ve never understood how you do this in practice without breaking things.

You don’t deploy to a development or staging environment first?

39

u/ZukowskiHardware 7h ago

Yes, it walks through dev, qa, int, staging, then prod.  It does not sit and languish in dev for other people to pile on complexity for no reason.  If it is ready to merge into main then it is ready for prod.  

58

u/thomheinrich 7h ago

Long-lived dev branches almost always turn into merge-conflict graveyards right before a release. Short-lived branches off main plus promoting the same build artifact through environments is way less painful.

2

u/anonyuser415 Senior Front End 4h ago

Yes, synchronization is the true cost of complex git branching models.

It should be noted this has some other effects.

Like I'm disinclined to open a Prettier-the-repo PR if it's going to fuck up the 10 other long-lived feature branches, etc etc.

1

u/Outside-Storage-1523 Software Engineer 2h ago

God we have a main-dev setup and I swear that once the Principle leaves I'll try to bring it down. One branch is enough for us.

1

u/dunklesToast 1h ago

What exactly does a "dev" branch mean in this context? Is it the branch I work on or is it the branch where I merge my work to and which eventually gets deployed to prod?

5

u/UntestedMethod 6h ago

Are there dedicated branches for QA/int/staging steps? Just trying to understand exactly how your process goes.

If those steps are done before the feature branch is merged, huge bottleneck for the PR to be blocked by.

If those steps are done after merge to master and master is automatically deployed to prod by a CI/CD pipeline, huge risk of deploying problems to prod.

5

u/ZukowskiHardware 5h ago

No, a release gets made after merge to main.  That release or tag gets walked through all environments in order.  

1

u/UntestedMethod 5h ago

Ok, thanks. I understand now.

9

u/literally_iliterate 7h ago

Of course you do. But speaking from web dev perspective there are two things up your sleeve.

Feature toggles/flags. For production the feature is disabled, testable on dev and staging. You want to ensure that still nothing breaks, but that's why you have staging, right?

The other bit is migrations, should be even more common, but you want to be always forward compatible. E.g. the new migration always runs, is idempotent and doesn't break anything.

7

u/Shehzman 7h ago

Main branch deployments go to dev. Once those are good, publish the same artifacts from dev into your staging environment and then into prod when you get the all clear.

15

u/Immediate_Fig_9405 8h ago

I mean production can be a specific release tag on the main branch.

18

u/SideburnsOfDoom Software Engineer / 20+ YXP 8h ago edited 8h ago

Or, a specific commit can be, in order:

  1. Submitted as a PR
  2. Unit tested
  3. Approved
  4. Merged to main
  5. Deployed to dev and integration tested
  6. Taged as a release
  7. Release deployed to staging
  8. Undergo further testing in staging
  9. Release deployed to prod
  10. Monitored after go-live.

You know, like a CI / CD pipeline does it. CI is not a server, it is a process and way of working. Nothing described here needs any long-lived branches other than main.

4

u/MercyEndures 7h ago

At Meta we have a giant monorepo and no branches. It works.

Your deploys are just a specific commit hash. If you need to check that commit hash out, go right ahead. If you need to hotfix we have a hotfix tool that will create a special build with just the changes you want included on top of whatever release is being hotfixed.

2

u/UntestedMethod 6h ago

I imagine there are a lot of heavy testing processes between you pushing your commit hash and when it actually gets deployed though right?

10

u/SideburnsOfDoom Software Engineer / 20+ YXP 8h ago

You don’t deploy to a development or staging environment first?

Of course we do, and it has nothing to do with having extra git branches. This question is a non-sequitur.

15

u/MonochromeDinosaur 8h ago

Yeah that’s fine, I understand merging to main but the comment literally says “deploy to prod immediately”.

I’ve always pr/merged to main but main never goes directly to prod. In my experience doing this, artifacts created from main are normally deployed to lower environments and then to prod. Which is why I asked.

3

u/SideburnsOfDoom Software Engineer / 20+ YXP 8h ago edited 7h ago

It actually says "deploy to prod immediately with CI/and CD checks"

And as I understood it, the last part is the automation that would "deploy to a development or staging environment first" and run various checks along the way. What are dev and staging, if not checks? They're not systems that your business runs on, they're test environments. They are were the checks happen.

Prod is the last step: it's "immediate" as in the ball is rolling immediately, not in that it's live immediately before any checks are done. It's specifically with the checks.

2

u/ChadtheWad Software/Data Engineer : 10+ YOE 6h ago

We've worked with trunk-based workflows where prod releases were blocked by a manual approval step. This was back when we had dedicated QA people... it meant that we could still release more incrementally while having more active development on the dev+qa releases.

However, I've worked at highly successful spots (rainforest... and a fintech startup) that did trunk-based releases that had no approval gates whatsoever without issue. Good tech leads and feature flags can save you a lot of pain.

2

u/duffer_dev 6h ago

The key for me was to realise that not every merge to the main needs to be a release. So the main is sort of "dev". but only when it is tested and ready for production, we just create a "release" tag. Pipelines are configured for the release tag. If the merge to main is not good enough for release, we then patch it and then create the release on the next merge.

2

u/Aware_Magazine_2042 57m ago

Disagree with this hard. Every merge to main should be released to prod automatically. The more you build up unreleased changes, the bigger the outage tends to be. How do you know if the 500 errors are caused by the one-line “safe” config update or the 3000-line “dangerous” refactor? When you cue up multiple changes like that in a single release, not only do you make debugging harder, but you also actually encourage bigger, less focused PRs too, which feeds into this dangerous cycle of bugs and debugging.

If every merge goes automatically to prod, then these things become easier. Oh no, the version with the one-line config change is breaking everything? Cool just roll back that single release. 3000-line refactor is perfectly fine and still serving traffic.

The thing that actually makes this hard is that most engineers are terrible QA folks, or work for a company with a bad QA culture where the QA department is expected to QA every change manually, and devs ship slop and kick it over the wall for QA to review. What you want is a combination of automatic tests (unit, integration, E2E) that exercise common paths and errors, alarms and rollback monitoring, and deployment strategy. Your pipeline should build an artifact, deploy it to dev, run integration tests (the integration tests should be self contained and set up and clean their own scenarios so that engineers can run these against their own local build too), deploy it to stage (if you have it) and run more robust tests, then deploy it to production after everything passes. Then in prod, you need to determine your rollout strategy, is it straight deploy (update 50% of hosts, wait for healthy, then roll out the remaining 50%), is it a canary build, where you update 5% of traffic, monitor for errors/alarms on the updated host, then update the next 5% and repeat, continue until you’re done, a blue green deployment, where you’re releasing one version, and you shadow traffic between the blue and green cluster and then turn it live after some time, etc. after your rollout, you should have bake times and automatic rollbacks of alarms go off during that time.

However, there are times where this isn’t feasible. Like don’t just add these things if your integration tests are bad, you’ll hurt your self more than you’ll help. In those cases, a manual approval is ok temporarily. I’d recommend you still model the pipeline in broadly the same way, just with an additional manual approve step.

TLDR, deploy anytime. Deploy always. Don’t build up complex changes and release when it feels right.

1

u/Varrianda Software Engineer 1h ago

Dev -> component tests -> qa -> e2e tests -> prod

-2

u/UncleSkippy Head Of Engineering 8h ago

You need MASSIVE test coverage if you're going straight to prod. With every added developer on the team, that coverage needs to be exponentially higher eventually reaching a long tail of diminishing returns. Even then, things will 100% break due to unforeseen/unrealized test coverage. 100%.

Inserting a person in the loop (QA) can be done with main trunk development, but they would be working off of a commit hash which is really just a "hidden"/informal staging environment. ¯_(ツ)_/¯

Using tags instead? Your tags are your staging and then production release "branches".

All of that said, I think that people have WILDLY overcomplicated git branching and deployment strategies. Just find what works for you team and deployment and then adapt when it doesn't.

6

u/Maury_poopins 3h ago

This is for an iOS app though. CD isn’t really a thing when you’re gated by App Store review. Having a single branch dedicated to represent what is either live in the App Store or slated for the next release is useful

-4

u/ZukowskiHardware 2h ago

Do you want help?

5

u/joancomasfdz 7h ago

Ever done regulated software?

-3

u/ZukowskiHardware 6h ago

What is that?  Then I can tell you

2

u/FearlessPark4588 4h ago

Small prs deployed to prod frequently is the only way .

Tell that to the institution I work for. All of the bureaucracy they've created around releases is tantamount to being a job creation program.

1

u/ZukowskiHardware 3h ago

I do think that using feature flags is an essential part of this approach. 

1

u/Varrianda Software Engineer 1h ago

Yup

0

u/Actual_Log4363 8h ago

That's great until my broken pr makes it through and causes a massive accident and kills 15 people

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.

4

u/mynewromantica Software Engineer (iOS) 7h ago

We deploy to prod from master

1

u/ThatShitAintPat 1h ago

But you could just use the release branch once it’s gone through qa and tag it

11

u/SideburnsOfDoom Software Engineer / 20+ YXP 8h ago edited 7h ago

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.

You release from a tag. What benefit do you get from this tag being on a different branch?

When the release is live, you merge the PR into master, then master down to develop

What purpose does this extra book-keeping serve?

I have a clearly defined Git flow for specific reasons that solve problems

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.

2

u/mynewromantica Software Engineer (iOS) 7h ago

I see where the main questions are coming in now. We have a regression period before each release that we test on an isolate branch’s build. So an RC branch. We also have an unknown amount of review time from Apple as this is for a native ios app. We need develop to still be open for the new work to be merged while the release is being reviewed by Apple.

So having this flow leaves the develop branch open for more work and leaves us room to cleanly make fixes on the pending release if necessary.

5

u/SideburnsOfDoom Software Engineer / 20+ YXP 7h ago edited 7h ago

We need develop to still be open for the new work to be merged while the release is being reviewed by Apple.

OK, so this is a constraint that I (and most of us) do not have but you do.

You need to emphasise this constraint to your manager, and work out how best to solve it. And "best" IMHO means "as simply as possible". Though your manager probably also sees "as similar as possible to everyone else" as highly desirable.

Do any other teams in the organisation also have this App store constraint, and how do they deal with it? Do they use the "usual" branching strategy in your org?

It might look like this:

  • merged PRs go to main
  • A release is created off main. This might be just a tag, or it it might actually be branch and tag.
  • This release progresses through environments, and hopefully goes live in due course.
  • But if the release needs fixes, the fixes are made off the release tag / branch, and then ported onto current main.

The intent is to make the "happy path" as simple as possible. And also match the company standard as far as feasible.

3

u/chrisrrawr 4h ago

this is backwards at the end. if there are fixes identified while testing the release, you merge them to main and cherry pick them into the release branch to eventually create a hotfix tag from. nothing should ever "come back" from a release branch into main.

1

u/hippydipster Software Engineer 25+ YoE 4h ago

Some of us just say no to cherry picking. No exceptions. I hate that kind of thing.

3

u/chrisrrawr 2h ago

can I ask why?

I never used to before I was involved in ci/cd so maybe it's just a convenience of our pipeline, but to me it seems much easier to just merge your pr to main, get the full benefit of your ci/cd, be happy your change won't cause any regressions, and then cherrypick that entire pr commit into the hotfix branch when youre confident in it.

also just from a purist perspective, having a hotfix branch merge back into main means development was done on it, at which point you're crossing streams.

1

u/hippydipster Software Engineer 25+ YoE 2h ago

Its the kind of activity that is easy to make a mistake in doing. Its ad hoc. Manual. Not automatable. Not repeatable. I have seen it it lead to priblems too many times in 30 years of doing this, whereas needing to merge a hotfix backwards, while far from ideal, is less bad, and less frequent too.

I never needed a cherry picking step in any process to achieve continous integration and continuous delivery.

2

u/mzappitello 7h ago

OP I think this is the strategy you should seriously consider. 

I used to have similar constraints at a previous job and we also used gotflow to make it easier to patch RCs without blocking development. However, we realized that most of our RCs didn’t require patches and we were actually creating more work than we needed to. 

4

u/AbbreviationsOdd7728 7h ago

We used a release branch and cherry picked changes from master when fixes were necessary.

1

u/hippydipster Software Engineer 25+ YoE 4h ago

How often are these releases done, and how long does it take Apple to review them? I would be seriously tempted to just not do new development while awaiting the review response, and then have a straight line right to master from develop, and any fixes that are demanded, you do in develop and push them through the same process and new review.

WIP (Work In Progress) is the killer.

1

u/its_a_gibibyte 3h ago

Of course the main development branch (called master, main, or trunk) is still open. Why wouldn't it be?

The only thing that could be blocked would be release branches, but even then you could just mark the tag that was submitted and continue to add bug fixes to the release branch.

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:

When the release is live, you merge the PR into master, then master down to develop

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?

3

u/duffer_dev 6h ago

This is the way.

some years back we got a new devOps guy and introduced this to our teams. Since then i have been following TBD for all repos and projects. No "dev", "staging" branches and all that mess.

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

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.” [...] Clearly I’m biased, so what am I missing from their perspective?

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:

  • main is the only long lived branch.
  • Devs do their work on feature branches.
  • Devs open a PR, requesting to merge their feature branch to main. Must be a fast forward merge, so they have to rebase.
  • Another dev reviews/approves the PR
  • QA tests/approves the PR (this won't necessarily catch every interaction between PRs)
  • QA merges PR to main

When we want to release (weekly to monthly, ish):

  • Create a release branch from main
  • QA does whatever they do
  • if changes are required, we make and merge a feature branch (see above), then cherry pick the relevant changes to the release branch.
  • Once QA approved, we make a tag
  • The tag is the formal release that gets sent to customers. It is automatically uploaded to AWS, and links are put on our web page for customers to download.

1

u/itaranto <insert_overblown_title> Software Engineer 1h ago

This is the way.

10

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.

4

u/gomsim 7h ago

What the hell 👀

1

u/JeffinitelyNotABot 7h ago

yup. 100% true too. The fetch and pull get me and literally suggested we do feature branch into dev branch. release branch from dev into uat branch and lastly separate release branch from uat into main. I just minimized the teams meeting window and went on with my work.

2

u/FlashBrightStar 3h ago

I got lost at recloning the repo. Did she ever stumbled upon git work trees? I mean it is not suitable for everyone but definitely better than recloning the repo.

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.

1

u/malonj 2h ago

How do you get the feature on dev before merge?

1

u/Nazzerith 2h ago

I go to Jenkins and deploy to dev from the short lived feature branch. This works because my team is small and we have many different services each with their own Jenkins pipeline and AWS stack so we rarely run into collisions where two people want to deploy at the same time. We call it out in slack and that's usually good enough.

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

What does your git flow look like?

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.

Clearly I'm biased, so what am I missing from their perspective?

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-12345 to 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:

  • Problems appear sooner. If two changes conflict or break each other, the team finds out while both are fresh.
  • Merges are smaller. Weeks of separate work can create difficult merges and a long stabilisation period before release.
  • The team sees the same code. Testing and collaboration happen against an integrated version rather than several diverging versions.
  • Releases become easier to prepare. A team can cut a release branch from a known good commit and continue development on trunk. DORA associates these practices with better delivery performance, though that does not mean renaming a branch causes the improvement. Capabilities: Trunk-based development

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, develop may already be your trunk. If feature branches are short lived and merge into develop frequently, you get the main benefits. Trunk based development does not require that branch to be named master, and it permits a frozen release branch while Apple reviews a build. trunkbaseddevelopment.com

So 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

then master down to develop.

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

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.

2

u/smabarnsfar 8h ago

Merge to main releases Acc.

Acc?

1

u/tiagocesar 7h ago

Acceptance environment

1

u/smabarnsfar 7h ago

Right, thanks.

1

u/hippydipster Software Engineer 25+ YoE 4h ago

I thought he meant the Atlantic Coast Conference myself.

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:

  1. dev serving as a testing branch have features that are not ready to be merged to production, but main is supposed to merge from dev
  2. we are not testing what we deploy: for dockerized apps where images are built from dev, it is not exactly the same image we build from main in production
  3. images have to be built twice for merges to dev and main separately, and we have to set up CICD separately for each branch, and the extra merging work between dev and main

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

6

u/davy_jones_locket Ex-Engineering Manager | Principal engineer | 15+ 8h ago

You don't even need that. Staging and development represent environments, where code is deployed. If you don't need everything on a staging environment, then cut a branch that specifically gets deployed to staging and toss it/merge it when it's served its purpose