git branching for agile teams

93
Git Branching for Agile Teams

Upload: atlassian

Post on 10-Jul-2015

5.302 views

Category:

Software


0 download

DESCRIPTION

Git helps agile teams unleash their potential. https://www.atlassian.com/

TRANSCRIPT

Page 1: Git Branching for Agile Teams

Git Branching for Agile Teams

Page 2: Git Branching for Agile Teams

Why use Git + agile?

Page 3: Git Branching for Agile Teams

Git helps agile teams unleash their potential

Page 4: Git Branching for Agile Teams

Developer

How?

Page 5: Git Branching for Agile Teams

First, let’s review two pillars of agile

Page 6: Git Branching for Agile Teams

1

Build in narrow vertical slices

Page 7: Git Branching for Agile Teams

Waterfall: can’t release anything until everything is ready to release

DATA BA S E

BAC K E N D

F R O N T E N D

T E S T I N G

“big bang” launch

Page 8: Git Branching for Agile Teams

DATA BA S E

BAC K E N D

F R O N T E N D

T E S T I N G

MVP launch

Agile: something can get released fairly quickly

Page 9: Git Branching for Agile Teams

Modularity for the win!

Page 10: Git Branching for Agile Teams

Or to put it another way…Potentially shippable, even without this piece

I have a roof!

Page 11: Git Branching for Agile Teams

The modular house may not have all its

components, but it’ll be move-in ready first

Page 12: Git Branching for Agile Teams

Modularity enables teams to have something testable

—and potentially shippable— much sooner

Page 13: Git Branching for Agile Teams

2

Make releases a non-event

Page 14: Git Branching for Agile Teams

A big bang style release (everything at once)

means dependencies up the wazoo

Page 15: Git Branching for Agile Teams

Look familiar?

Just a few dependencies...

Page 16: Git Branching for Agile Teams

Do you hold everything in a local workspace until the entire user

story is implemented?

Page 18: Git Branching for Agile Teams

That would mean an important practice for agile

teams wasn’t followed: continuous integration

Page 19: Git Branching for Agile Teams

Continuous integration, noun: Testing changes against the existing code base and in-progress changes from the team throughout the development cycle.

Page 20: Git Branching for Agile Teams

Sure CI is important, but…

Page 21: Git Branching for Agile Teams

Will frequent, incremental changes to the repo introduce

more risk?

Page 23: Git Branching for Agile Teams

But only if all those changes are piled on the primary code line

Page 24: Git Branching for Agile Teams

The idea is to push changes to the repo without de-stabilizing the primary code line

Page 25: Git Branching for Agile Teams

That’s where Git comes in

Page 26: Git Branching for Agile Teams

Tell me more!

Developer

Page 27: Git Branching for Agile Teams

branching & merging is hell

In Subversion

Page 28: Git Branching for Agile Teams

branching & merging is easy

In Git

Page 29: Git Branching for Agile Teams

It’s all in the way data and histories

are tracked

Page 30: Git Branching for Agile Teams

Git stores data as a series of snapshots

(rather than changesets)

Page 31: Git Branching for Agile Teams

If SVN is a hand-drawn map,

Git comes with built-in GPS

Page 32: Git Branching for Agile Teams

Git uses triangulation to figure out what the

merged version should look like on its own

Page 33: Git Branching for Agile Teams

But enough about the technical

underpinnings

Page 34: Git Branching for Agile Teams

Git enables a dev to fully exploit the power of branch-and-merge

workflows

Page 35: Git Branching for Agile Teams

Why use a branching workflow?

Page 36: Git Branching for Agile Teams

Branching protects the main code line, and

supports an individual developer’s workflow

Page 37: Git Branching for Agile Teams

Atlassian devs create a branch for each

issue they work on

Page 38: Git Branching for Agile Teams

And it’s helping us deliver faster than

ever before

Page 39: Git Branching for Agile Teams

Keep the main line clean

Dev branches are like an isolation

chamber

Page 40: Git Branching for Agile Teams

No half-baked code on the main line

Page 41: Git Branching for Agile Teams

There are other benefits, too…

Page 42: Git Branching for Agile Teams

Clarity & traceability

If it’s been merged up, it’s ready to release. Easy!

Page 43: Git Branching for Agile Teams

The branch-per-issue model is the synthesis of:

“build in narrow vertical slices” +

“make releases a non-event”

Page 44: Git Branching for Agile Teams

Branch-per-Issue Workflow

for SaaS teams

Page 45: Git Branching for Agile Teams

The basic idea: a master code line with several

development branches running alongside it

Page 46: Git Branching for Agile Teams

A branch for every issueKeep master green

feature/DEV-30

feature/DEV-45

master

Experiment on your feature branch

Page 47: Git Branching for Agile Teams

Creating a branch

feature/DEV-30

master

Check your CI system to make sure you’re creating your dev branch from a clean commit!

Page 48: Git Branching for Agile Teams

Break all the tests on a branch without

disrupting teammates

Page 49: Git Branching for Agile Teams

Merge up when work is done

feature/DEV-30

master

With implementation complete, and CI passing, merge upstream! On some teams, the product owner acts as a “gatekeeper,” selecting branches for merge based on what they want to release.

Page 50: Git Branching for Agile Teams

The beauty of this branching model:

Page 51: Git Branching for Agile Teams

Code changes that are breaking tests on a dev branch

aren’t affecting master or impeding the team’s ability to

release from master

Page 52: Git Branching for Agile Teams

It’s easy to control what is released to users and

what is held back

Page 53: Git Branching for Agile Teams

Now, a variation on that model:

Page 54: Git Branching for Agile Teams

Using an Integration Branch

Page 55: Git Branching for Agile Teams

The basic idea: a shared integration branch running between feature branches

and the master branch

Page 56: Git Branching for Agile Teams

But what if teammates merge incompatible changes upstream?

Page 57: Git Branching for Agile Teams

Surprise!

feature/DEV-30

feature/DEV-45

master

Page 58: Git Branching for Agile Teams

Now master is broken

Page 59: Git Branching for Agile Teams

And that’s sad

Page 60: Git Branching for Agile Teams

Some teams avoid this by using a shared branch

to integrate changes during development

Page 61: Git Branching for Agile Teams

Builds fail on the integration branch,

not the release branch

Page 62: Git Branching for Agile Teams

Using an integration branch

integration

feature/DEV-30

master

feature/DEV-45

Page 63: Git Branching for Agile Teams

Merge all clean CI runs on the dev branch to the integration branch and run CI

Page 64: Git Branching for Agile Teams

If changes don’t play well with changes made by teammates, go back

and fix the branch

Page 65: Git Branching for Agile Teams

When implementation is done and CI on the

integration branch is clean, it’s ready to merge to master

Page 66: Git Branching for Agile Teams

Branch-per-Issue Workflow

for installed app teams

Page 67: Git Branching for Agile Teams

Multiple-version support

master

v 1.2

v 1.1

feature/DEV-30

Page 68: Git Branching for Agile Teams

In this model, master acts as an

“alpha” branch

Page 69: Git Branching for Agile Teams

Devs make branches off of master for

new development

Page 70: Git Branching for Agile Teams

And run CI, maybe use an integration

branch, etc.

Page 71: Git Branching for Agile Teams

Then a stable version branch is cut just

before release time

Page 72: Git Branching for Agile Teams

Create a bugfix branch off the release branch

and fix the problem there

Page 73: Git Branching for Agile Teams

Multiple-version support

master

v 1.2

bugfix-DEV 32

feature/DEV-30

Page 74: Git Branching for Agile Teams

Then cascade the fix back to the stable version

branch and master

Page 75: Git Branching for Agile Teams

Incorporating Agile Best Practices

Page 76: Git Branching for Agile Teams

Continuous Integration & Peer Review

Page 77: Git Branching for Agile Teams

Running CI on dev branches

All active branches are under test

Page 78: Git Branching for Agile Teams

Yes: all active branches

Page 79: Git Branching for Agile Teams

But that can clog the

build queue

Zzzz

Page 80: Git Branching for Agile Teams

Balance testing rigor and resource conservation

with manually triggered builds on dev branches

Page 81: Git Branching for Agile Teams

Triggering CI

master

v 1.2

feature/DEV-30

Developer

Automation

Page 82: Git Branching for Agile Teams

What about code reviews?

Page 83: Git Branching for Agile Teams

With Git, use pull requests to integrate

peer review into the workflow

Page 84: Git Branching for Agile Teams

Using pull requests1

2

3

Create request via UI or git request-pull

Review, revise, rinse & repeat

Approve & merge

Page 85: Git Branching for Agile Teams

Additional Considerations

Page 86: Git Branching for Agile Teams

Is “pure” continuous integration in a

branch-per-issue model possible?

Page 88: Git Branching for Agile Teams

For a CI purist, that matters

!

For a CI pragmatist, it doesn’t

Page 89: Git Branching for Agile Teams

But shared integration branches and pulling updates from master

down to dev branches comes close to “pure”

Page 90: Git Branching for Agile Teams

And this workflow is so powerful for agile teams, it’s

wise to be practical

Page 91: Git Branching for Agile Teams

Here’s to easy releases, happy developers, and

getting Git right!

Page 92: Git Branching for Agile Teams

More info

1 http://atlassian.com/git

2 @Atlassian