from Hacker News

Ask HN: What Git branching strategy do you use in 2023, and why?

by rufugee on 2/27/23, 6:06 PM with 16 comments

I'm working with a new small team (less than 8) and converting them to Git. It's been awhile since I started with a green field when it comes to branching strategy. What do you follow in 2023, and why?
  • by sys42590 on 2/27/23, 7:02 PM

    My personal recommendation:

    Development happens on short lived branches, gets merged to master via pull request after code review if needed, but at least some automated testing should be done.

    NEVER DO MERGE COMMITS: Always rebase + fast forward merging only.

    Branches that never reached production and likely never will should be discarded after a while.

    Branches that reached production e.g. hotfix branches should be converted to tags after a while.

  • by superdeeda on 2/28/23, 8:55 PM

    Github flow [1] for me - which is basically what others have mentioned about branching feature branches directly from main and merging as soon as the pull request is approved.

    [1]: https://githubflow.github.io/

  • by paiute on 3/2/23, 4:46 PM

    I personally prefer a simplified version of git-tag-flow: https://github.com/vasdee/git-tag-flow

    I hate git-flow with a passion.

  • by PaulHoule on 2/27/23, 6:28 PM

    I work in a feature branch, the tech lead does a code review (for real!) then merges to develop, the tester tests the develop branch, if it passes that gets merged to the master branch, the prod system is updated, the tester tests it again.
  • by sethammons on 2/28/23, 1:04 AM

    Short lived branches. If tests are green and it passes code review, squash merge, bump the release, and deploy. Never force push anything ever. Rewriting history is bad.

    It is all about reducing feedback cycles.

  • by Daedren on 2/27/23, 6:12 PM

    Still on Gitflow.

    It's rather simple for a new employee to understand, meshes in nicely with CI/CD systems and the release processes of the places I worked at.