1

We currently support two branching strategies; gitflow and trunk-based dev. My company started using what I'd call a hybrid (read not correctly IMO) gitflow model, but the direction of the company is to move to trunk-based development. I like the direction, but what's the best way to do this? I'm looking for best practices, but was unable to find this topic discussed online.

We use GitHub for SCM

In our hybrid gitflow branching strategy, our git projects are not currently (IMO) using the gitflow "master" branch correctly.

Should we:

  • Create new git projects in GitHub and archive the older gitflow based git projects
  • Block access to the "master" branches in the gitflow based git projects
  • Delete the "master" in the gitflow based git projects, and then follow trunk-based dev

Thanks

sleon
  • 173
  • 1
  • 13

1 Answers1

1

I was in a similar situation and wanted to switch from Git-Flow to Trunk-Based development.

This is how I ultimately solved the dilemma of a headache-filled attempt of merging massive amounts of code from 'dev' to 'master/main':

TL;DR: Replace 'main/master' with 'dev's code entirely, in your OS. Commit changes. Merge 'dev' into 'master/main'. Lock dev.

Detailed process -

  1. Switch to 'dev' branch
  2. Make a copy of 'dev' on your local drive in another folder
  3. Switch to 'master/main'
  4. Delete all contents from your local drive for this branch's folder, EXCEPT for the .git folder
  5. Copy all the contents, EXCEPT the .git folder, from the backup/copy of 'dev' from step 2 to the 'master/main' branch's folder
  6. Do a 'git status' and see that there are a ton of changes
  7. git commit, and git push

Now your 'master/main' contains exactly what 'dev' does.

  1. Finally merge 'dev' into 'master/main' so history/tooling shows that they converged
  2. Lock the dev branch
  3. Implement Trunk-Based development and CI best practices

Best wishes!

tcables
  • 1,231
  • 5
  • 16
  • 36