Git With the Flow!

maintainable git branching strategies

@terminon

github.com/bloveridge

Ben Loveridge

FOLLOW ALONG

bnjm.in/git-strategies

bnjm.in/git-strategies-feedback

LEAVE FEEDBACK

JOIND.IN

joind.in/14039

CODE IS KING

Developer cost

Branching cost

$$$

$

~40 bytes

Poor branching strategy

$$$$

Everything on master

Last good state?

Mistakes break everyone

Leads to big commits

Everything on master

You're probably branching without realizing it.

Branch per release

What is deployed?

Where do fixes go?

Branch per release

Branch per developer

What is being worked on?

How do you switch tasks?

When do you integrate?

Branch per developer

MERGE HELL

What to do?

When do you typically release?

Planned releases

gitflow

    1. http://nvie.com/posts/a-successful-git-branching-model/

   2. http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/

Continuous release

github flow

    1. https://guides.github.com/introduction/flow/

   2. http://scottchacon.com/2011/08/31/github-flow.html

gitflow

It's not as scary as it looks.

Primary Branches

Development branch

Deployment branch

Feature branches

Secondary Branches

Release-prep branches

Hotfix branches

Support branches

Long-lived branches

development

production

Branch naming

"development"

"production"

Feature development

Feature development

$ git checkout -b feature/cart development

$ git commit

$ # rinse and repeat

$ git checkout development

$ git merge --no-ff feature/cart

$ # cleanup

$ git branch -d feature/cart

Feature development

git-flow-avh

Feature development

$ git flow feature start cart

$ git commit

$ # rinse and repeat

$ git flow feature finish cart

Feature development

Preparing a release

Preparing a release

Merge tag into development to keep git-describe awesomeness.

Preparing a release

$ git flow release start 4.2.2

$ vim package.json # update version in package file

$ git commit

$ git flow release finish 4.2.2

Preparing a release

$ git checkout -b rel/4.2.2 development

$ vim package.json # update version in package file

$ git commit

$ git checkout production

$ git merge --no-ff rel/4.2.2

$ git checkout development

$ git merge --no-ff 4.2.2

$ git tag -a 4.2.2

Quick, push a hotfix!

Quick, push a hotfix!

$ git flow hotfix start 4.2.3

$ git commit # fix bug

$ vim package.json && git commit # update version in package file

$ git flow hotfix finish 4.2.3

Quick, push a hotfix!

$ git checkout -b hotfix/4.2.3 production

$ git commit # fix bug

$ git commit # update version in package file

$ git checkout production

$ git merge --no-ff hotfix/4.2.3

$ git checkout development

$ git merge --no-ff 4.2.3

$ git tag -a 4.2.3

Support old versions :(

Support old versions :(

$ git flow support start 1.8.6 1.8.5

$ git commit # fix bug

$ git commit # fix more bugs

$ git tag -a 1.8.6 # tag if you want to, but don't merge it

Support old versions :(

$ git checkout -b support/1.8.6 1.8.5

$ git commit # fix bug

$ git commit # fix more bugs

$ git tag -a 1.8.6 # tag if you want to, but don't merge it

github flow

Primary branches

Master branch

Feature branches

Feature development

Preparing a release

. . . um, we did that already.

summary

Pros

  • good production code always available
  • bug fixes get where they belong
  • release when you're ready
  • supports multiple versions
  • helpers make it quick and easy

Cons

  • multiple long-running branches
  • looks like a lot of steps
  • can feel slower and less agile

gitflow

Pros

  • deploy early, deploy often
  • one branch to maintain
  • integrate often; very agile
  • simple even without helpers

Cons

  • feature toggles
  • doesn't support multiple versions

github flow

Questions?

bnjm.in/git-strategies-feedback

JOIND.IN

joind.in/14039

Leave feedback

Resources

https://guides.github.com/introduction/flow/

http://scottchacon.com/2011/08/31/github-flow.html

http://nvie.com/posts/a-successful-git-branching-model/

http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/

https://github.com/petervanderdoes/gitflow

Git With the Flow!

By Ben Loveridge

Git With the Flow!

Creating branches in git is easy, fast, and cheap. When used well, branches can be a powerful tool for good in keeping your code progression and release cycle clear and understandable. When used poorly, branches can make your commit history unhelpful, confusing, or even downright unreadable. We will talk about two popular git branching strategies: Git Flow and GitHub flow. We'll discuss some of the pros and cons of each branching strategy, and what type of deployment strategy each workflow is best suited for. You'll know when to use a feature branch, why you should avoid support branches, and how to quickly fix bugs using a hotfix. Git workflows are strategies, not extensions--the only tool you need is the `git` command! That said, once you know the drill, we'll show how using some simple tools and aliases can make your workflow effortless.

  • 3,150