git workflows á la-carte, presenation at jdays2013 by nicola paolucci

Post on 06-May-2015

320 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Git Workflows A-la-carte, Presenation at jdays2013 www.jdays.se by Nicola Paolucci

TRANSCRIPT

Workflows á-la-carte

Nicola PaolucciDeveloper Advocate / Git Evangelist

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

Cheap local branchingFull local history

Speed

Staging area

prominent in Open Source

Huge community

You heard has

Feature based workflow

10x the speed of svn

Distributedcryptographic integrity

ground breaking paradigm is ground breaking

Workflow building blocks

rebasepowerful merging

fork

clone

cheap branching

distributed

RELEASECan we fix a bug for the

upcoming?

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?

Practices & Decisions

1

2

What we’ll cover:

Branching models

Tooling & Automation3

4 Continuous Integration

Which branching model?1

Product Releases

1 Continuous Delivery

2

Two common Branching Models

1.1 for Continuous Delivery

Tim

emaster/

productionstagingfeature

master is in production

staging is the next version

new features off staging

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

promoted from staging, can receive hotfixes

Hotfix

PR

for Product Releases1.2

One 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

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!

PRJ-

345-

bug-

desc

ript

ion

Tim

e

release branch

master

2.2

release branch

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 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 Continuously Never

Less stable than its baseline When code complete Continuously

Release branch

Release branch

Feature branchesCredit: Laura Wingerd - The Flow of change

The merge protocolThe secret sauce

Release branch

Release Branch

Master

Merge continuously

Backport single changes using git cherry-pick

Never merge!

Practices & Decisions2

turbo boost!

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?

Does a debate even exist?

Merge vs Rebase

MER

GE REBA

SE

master

feature

What is a Rebase?Merge commit

master

feature

Traceability1

At a cost: readability2

3

Merge as team policy

bisect debugging is harder

with no fast-forwards

History flat and clean1

Delicate with Pull Requests

Dangerous for unexperienced

2

3

Rebase as team policy [1]

Re-resolve similar conflicts4

Requires often a force push

Loses context for feature

5

6

Rebase as team policy [2]

Do it1

Do it

Do it!!!!!!

2

3

Rebase as a local cleanup

git rebase --interactive

If team unfamiliar, don’t rebase1

Encourage rebase as cleanup2

Recommendation?

and proper ecology

Don’t fear the Merge! Use it!3

May rebase feature branches

Work with the tool!

4

5

Recommendation?

git log --first-parent

Trying to strive for a linearized history is less useful than you think

To update the feature branch

Explicit merges into the mainline

After review!

Single Repository vs

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

ENTERPRISE5 Reasons for...

REASON 1

Great for customizing librariesand still get bug fixes

REASON 2

Great for innovation spikesand maybe add it later

FORKING IN

ENTERPRISE

REASON 3

Protecting your components

but still be open for changes

FORKING IN

ENTERPRISE

REASON 4

Reduce the noise

and keep the overview for huge projects

FORKING IN

ENTERPRISE

REASON 5

Interaction with Contractors & Interns

protect your sources

FORKING IN

ENTERPRISE

Tooling & Automation3

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 via pre-commit hooks

.git/hooks/pre-commit!

git add -u!git 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 master!master 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

4 What happens to CI with ?

What happens to CI with git?1

An explosion of branches2

3 Performance degradation of build sys

Building everything is expensive1

Automatically build stable and master2

3 Manually trigger feature branch builds

In Conclusion: the recipe

!!!

!!!!!

Branching Model

Practices & Decisions

Automation & CI setup

Conclusions

!!!!!

Product workflow

Continuous delivery workflow

Embrace PR

Build automatically,

but leave knobs!Single Repo

or Forks

!!!

Collaboration Model

Centralized

Hooks, hooks everywhere

Merge vs Rebase

Nicola PaolucciTHANK YOU FOR YOUR ATTENTION!

@durdndurdn.comShould I change the pic? ;-)

http://strawpoll.me/774809

Git Repository Management for Enterprise Teams

Free Git Code Hosting for Small Teams

Free Git Desktop client for Mac or Windows

Atlassian

top related