jazoon'13 - stefan saasen - real world git workflows

Post on 10-May-2015

1.201 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Real World WorkflowsStefan Saasen

TODO Show of hands

Picture with hands/lighter/concert

git

Subversion

NO VCSAT ALL?

you must love pain

Stefan SaasenAtlassian Stash Development Lead

I come out nice in pictures, I know :-). @stefansaasen

Cheap local branchingFull local history

Speed

Staging area

prominent in Open Source

Huge community

You heard has

Superior Merging

Much faster than svn

Distributedcryptographic integrity

ground breaking paradigm is ground breaking

Workflow building blocks

rebasepowerful merging

fork

efficient clone

cheap branching

distributed

RELEASECan we fix a bug for a

specific?

FEATUREIs the code for that

complete?

BUILDCan we

the current code ?

REVIEWEDHas everybody

the code for this feature ?

HOTFIXCan we do a fast

for the current release?

DIFFERENTPEOPLEPRODUCTSCULTURES

DIFFERENTPEOPLEPRODUCTSCULTURES

DIFFERENTPEOPLEPRODUCTSCULTURES Stash, Bitbucket, JIRA

DIFFERENTPEOPLEPRODUCTSCULTURES

DIFFERENT WORKFLOWS

1

Practices & Decisions

2

3

Collaboration model

We’ll cover:

Branching model

Tooling & Automation4

Which collaboration model?1

Easy, right?

Fully decentralized Anarchy

I do my thingI do my thing, too

ANARCHYhere’s mine, who tells

john?look ma, a goat!

Blessed repository with Gatekeeper

He is cool

Gatekeeper

To have your work accepted, talk to him

and LieutenantsDictator

long live the King!

Lieutenants guardthe King

Blessed repository

Shared common repository

we share “everything”

Centralised

atlassian.com/gitMore on Collaboration models

+ = Centralized

Enterprise

Builds

Metrics

Issues

Deployments

They know where the code needs to go!

Which branching model?2

Product Releases

1 Continuous Delivery

2

Two common Branching Models

2.2 for Continuous Delivery

Tim

emaster/

productionstagingfeature

master is in production

staging is the next version

new features o! staging

with branch names like: username/ISSUE-KEY-summary

promoted from staging, can receive hotfixes

Hotfix

PR

Significant branches map to a concept in the outside world. It may be a past release, an environment or a role.Those branches are long-running and stable whereas feature branches are short lived and volatile.Me, just making this up. ”

for Product Releases2.1

Central Repository1

One Branch per Feature

One Branch per Bugfix

2

3

Tim

emasterfeature

branches

PRJ-

123-

desc

ript

ion

Tim

emasterbugfix branch

PRJ-

123-

bug-

desc

ript

ion

Short lived

Release Branches4

master is alpha / RC5

Long running

Tim

emasterrelease

branch

PRJ-

345-

bug-

desc

ript

ion

bugfix

2.2

Automatic merges for the win!

Tim

e

release branch master

2.2

release branch

PRJ-

345-

bug-

desc

ript

ion

bugfix

2.1

Automatic MERGES!

Placeholder for changes you DON’T want to merge!

release branch

2.2

release branch

2.1

2.1.4

2.2.1

We don’t want to merge the 2.1.x version!

2.1.5-SNAPSHOT

What can we do here?

git mergegit merge --strategy= resolve

git merge --strategy=recursive

git merge --strategy= ours

stable branch

2.2

stable branch

2.1

2.1.4

2.2.1

2.1.5-SNAPSHOT

merge commit, content discarded$> git checkout stable-2.2

$> git merge -s ours stable-2.1

Deep breath, it’s really simple

The merge protocolThe secret sauce

Release branch

The merge protocolThe secret sauce

When a branch is: Change flows from branch to baseline:

Change flows from baseline to branch:

More stable than its baseline

Less stable than its baseline

Continually Never

When code complete Continually

Release branch

Release branch

Feature branchesCredit: Laura Wingerd - The Flow of change

The merge protocolThe secret sauce

Release branch

Release Branch

Master

Mergecontinually

Backport single changes using git cherry-pick

Never merge!

3

turbo boost!

Practices

What is a Pull Request?

Hey I have some code I want to merge here,

take a look?

Low friction collaboration

Pull Request

I have some code here!

Can I merge it here?

Single Repositoryvs

Remote Forks

Every one has their remote repository

With Forks

Full remote copy,each has one Integrator, Gatekeeper,

Tech Lead, etc.

Complete visibility1

No per Dev remotes required

KISS

2

3

Pros of a Single RepoAll feature branches available

Forks Are Great too BTW

FORKING IN THE

ENTERPRISE

FORKING IN THE

ENTERPRISE4 Reasons for...

REASON 1

Great for customizing librariesand still get bug fixes

REASON 2

Great for innovation spikesand maybe add it later

FORKING IN THE

ENTERPRISE

REASON 3

Protecting your components

but still be open for changes

FORKING IN THE

ENTERPRISE

REASON 4

Reduce the noise

and keep the overview for huge projects

FORKING IN THE

ENTERPRISE

Tooling & Automation4

Hooks

Hooks are little scripts you can place in

the `$GIT_DIR/hooks` directory to trigger

action at certain points.

– githooks Documentation

”“

Pre Post

Local Remote

Local Remotepre-receiveupdatepost-receivepost-update

pre-/post-applypatchpre-/post-commit

pre-rebasepost-checkout

post-mergepre-push

Code Quality

.git/hooks/pre-commit

git add -ugit commit -m "TEST checkstyle"

Starting audit...

/Users/user/[...]/com/atlassian/stash/web/projects/ProjectController.java:161:12: 'for' is not followed by whitespace.

Audit done.Commit aborted.

Branch from green builds

.git/hooks/post-checkout

$ git checkout mastermaster is lookin'good! c4f3b4b has 4 green builds. $ git checkout stable-2.3 DANGER! stable-2.3 is busted. e1324fa has 2 red builds.

Get it at: bitly.com/green-builds

What happens to CI with git?

1 An explosion of branches

2

3

Performance degradation of build sys

Building everything is expensive

Automatically build stable and master1

Manually trigger feature branch builds2

In Conclusion: the recipe

BranchingModel

Adopt GitPractices

Automation & CI setup

Conclusions

Product workflow

Continuous delivery workflow

Embrace PR

Build automatically,

but leave knobs!Single Repo

or Forks

CollaborationModel

Centralized

Hooks, hooks everywhereMerge

protocol

Thank you for yourattention!

@stefansaasen

ssaasen@atlassian.comwww.atlassian.com

top related