getting git right

202

Upload: sven

Post on 08-Sep-2014

33 views

Category:

Technology


4 download

DESCRIPTION

When you get Git right, it can help you write cleaner code, roll out new features faster, and make your entire development team more efficient.

TRANSCRIPT

Page 1: Getting Git Right
Page 2: Getting Git Right

his smile is contagious :D

Nicola PaolucciDeveloper Advocate / Git Evangelist

Sven PetersAtlassian Ambassador

@svenpetsvenpet.com

@durdndurdn.com

checkout his stare :D

Page 3: Getting Git Right

Productive TeamsHappy Developers35 min 35 min

Page 4: Getting Git Right

Who knows

?

Page 5: Getting Git Right

?

doesn’t

Who know

Page 6: Getting Git Right

Facts

300 Developer

Page 7: Getting Git Right

Facts

750 Nerds

Page 8: Getting Git Right

Facts

working on 9 products

Page 9: Getting Git Right

Facts

on 4 Continents

Page 10: Getting Git Right

SoftwareWe

or in just 3 words

Page 11: Getting Git Right

SoftwareWe Teams

Page 12: Getting Git Right

really small team

they know what’s going on!

Let’s do it!

Great idea!

Productivity++

Page 13: Getting Git Right

team is growing

Let’s do it! Great! Why?

Who will do it?Is it done? Have you

talked to QA?

I have no time for this!

Productivity?

Page 14: Getting Git Right

Productivity??

we’re not alone

Is it profitable?!

When is it done?!

Page 15: Getting Git Right

is a

Devel ping S ftware

S cial Challenge

Page 16: Getting Git Right

Tools

efficient collaboration

transparent dev processshare knowledge

fast feedback

Page 17: Getting Git Right

Tools

happy developers & productive teams Ship software

faster & smarter

Page 18: Getting Git Right

Ship software faster & smarter

happy developers & productive teams

Page 19: Getting Git Right

Our journey to

Page 20: Getting Git Right

Great!

+Be the change

you seek

Page 21: Getting Git Right

Technical side Human side

Page 22: Getting Git Right

Technical Side: We’ve got you covered

Scripts Documentation

Page 23: Getting Git Right

S V NG I T

atlassian.com/git/migration

Technical Side: We’ve got you covered

Page 24: Getting Git Right

identifying champions staff training not everyone was happy

Human Side: Most important aspect!

Page 25: Getting Git Right

At the end we migrated…

200+11

21,00047,228 commits

filescommittersyear’s work

and that is just for JIRA

Page 26: Getting Git Right

The Numbers

what is the industry doing?

Page 27: Getting Git Right

Git is on the rise

15%

38%

from 2011 to 2013Source: RedMonk Git Survey 2013

Page 28: Getting Git Right

Git will continue to grow!

63 %

37 %

December 2015

Git

CVS + SVN

Source: Atlassian Git Survey 2013

Page 29: Getting Git Right

Git works for the enterprise!

60%100+ developers

1,000+ employees

Source: Atlassian Git Survey 2013

Page 30: Getting Git Right

Git works for the enterprise!

27%

69%

use the cloud

develop on-premise

Source: CollabNet Git Survey 2013

Page 31: Getting Git Right

Git means fast releases

Git

SVN CVS

mainly daily - weekly

mainly monthly

Source: Atlassian Git Survey 2013

Page 32: Getting Git Right

Better code with Git

Code Reviewsare great for the code and the team!

Page 33: Getting Git Right

Better code with Git

Code Reviews when using GIT

+15% more

thank you Pull Requests!

Source: Atlassian Git Survey 2013

Page 34: Getting Git Right

is just a tool!

Page 35: Getting Git Right

How do you use ?

Page 36: Getting Git Right
Page 37: Getting Git Right

Happier Developerwith

Be a

Nicola Paolucci!Developer Advocate / Evangelist

Sven Peters!Ambassador

March 2014!with! and!

Page 38: Getting Git Right
Page 39: Getting Git Right

Time machine without paradoxes?

Page 40: Getting Git Right

Explore & Understand

1

3

Speed, Speed, Speed

Control and Assemble4

Why does make you happy?

2 Freedom & Safety

Page 41: Getting Git Right

1

Fast is the new Black

Speed, speed, Speed

Page 42: Getting Git Right
Page 43: Getting Git Right

Staying in the flow makes you happy and your

manager happy…

Page 44: Getting Git Right

Everything is local

Except push & pull

Page 45: Getting Git Right

Written in C by Linux kernel and filesystem

developers

Page 46: Getting Git Right

Read: fast :D

Page 47: Getting Git Right

But what if my repo is big?

446k lines of code added

1

3

Recent Linux kernel release (3.13) has 15+ million LOC

1,339 contributors4

2 12,000 non-merge commits

source lwn.net

Page 48: Getting Git Right

2 Freedom & Safety

Page 49: Getting Git Right

Fast Context Switching

Freedom to innovatewith

Page 50: Getting Git Right

Feature Branching

Page 51: Getting Git Right

Feature Branching

Page 52: Getting Git Right

Feature branches: local

git checkout -b new-branch creates a branch and switches to it

Page 53: Getting Git Right

Feature branches: published (remote)

git push origin new-branch pushes a local branch remotely

Page 54: Getting Git Right

git stash is awesomeIt’s a way to

temporarily save your work on a stack

Page 55: Getting Git Right

So if your boss comes screaming at your desk

Page 56: Getting Git Right

git stash create a patch without a hassle

Page 57: Getting Git Right

stash and branch FTW

trick close to my heart

Page 58: Getting Git Right

Local full clones

full local copy of the entire project in a new folder

(not common but very easy to do)

git clone folder1 folder2

Page 59: Getting Git Right

Safety

Page 60: Getting Git Right

Losing work is very hard

very very

Page 61: Getting Git Right

maybe your git server crashed and the hd is

corrupted?… no problem

Page 62: Getting Git Right

Redundancy, every developer has a clone

Page 63: Getting Git Right

Chain of unlosability (I coined a new word!)

Page 64: Getting Git Right

Recover a file

git checkout file-name

Page 65: Getting Git Right

Recover a commit

git checkout sha-1

git checkout ref (branch/tag)

or

Page 66: Getting Git Right

Print file as in branch

git show branch:path/to/file

can be any ref

Page 67: Getting Git Right

find a deleted method

git log -S<string> search through all history

Page 68: Getting Git Right

When all is lost, use the reflog

Page 69: Getting Git Right

What is the reflog?it’s a log of all the places where your

HEAD has been

garbage collected every

30 days

Page 70: Getting Git Right

More on recovery!http://atlss.in/git-armor

Page 71: Getting Git Right

Explore & Understand 3

Page 72: Getting Git Right

Inspect Everything

Page 73: Getting Git Right

= history superpowers

Hard Questions to git logAsk

-S string in all diffs--after,--before when?--author who did what

Page 74: Getting Git Right

Who deleted that?git log -1 -- [path] lists where a file was deleted

git log --diff-filter=D --summary lists all deleted files

Page 75: Getting Git Right

Where is that constant?

git grep <regexp> compare the speed between this and regular grep or ack…you’ll be blown

away

Page 76: Getting Git Right

have I merged this?

git branch --no-merged lists branches not merged

git branch --merged lists branches already merged

Page 77: Getting Git Right

Control and Assemble4

Page 78: Getting Git Right

Why merge is awesome !

with

Page 79: Getting Git Right

What is a merge?

Merge commit

master

feature

merges keep the context of the

feature’s commits

Page 80: Getting Git Right

git knows the ancestry

1

2

The merge is local

powerful merge strategies3

merge is better in git

Page 81: Getting Git Right

merge becomes a non-event

In most cases

Page 82: Getting Git Right

rebase: Fiddle with safety belts on

Page 83: Getting Git Right

master

feature

What is a rebase?It’s a way to replay

commits, one by one, on top of a branch

Page 84: Getting Git Right

feature

master

What is a rebase?preserving the order

of change-sets

Page 85: Getting Git Right

What is an --interactive rebase?

It’s a way to replay commits, one by one,

deciding interactively what to do with each

reword fixup

pick squash

edit exec

Page 86: Getting Git Right
Page 87: Getting Git Right

CUSTOMARY WARNING!

rebase rewrites history!

Treat this power with great care. Only rewrite history of local branches or…

Page 88: Getting Git Right

One more thing…

Page 89: Getting Git Right

is great for dating

Page 90: Getting Git Right

git dating fake!

Page 91: Getting Git Right

Explore & Understand

1

3

Speed, Speed, Speed

Control and Assemble4

Why does make you happy?

2 Freedom & Safety

Page 92: Getting Git Right

Happy Developerwith

A

Page 93: Getting Git Right

Productive Team withA

Page 94: Getting Git Right

Improving Code Quality

1

2

Efficient Workflows

Protects Code3

Why makes a team great!

4 Natural Fit

Page 95: Getting Git Right

Efficient Workflows

Page 96: Getting Git Right

upcoming Release ?

Can we still fix a bug for the

FeatureIs the code for that

complete?

for the current version?HotfixHow do we do

ReviewedHas everyone

the code for this feature ?

Page 97: Getting Git Right

Git workflow?What’s the best

We don’t know!

Page 98: Getting Git Right

+ different teams+ different products

different cultures

= different workflows

Git workflow?What’s the best

Page 99: Getting Git Right

DesignWorkflows

your own

Page 100: Getting Git Right

Issues Code

Page 101: Getting Git Right

Issues Code

#30

#45#45

#30

Page 102: Getting Git Right

Can’t be released right now

Unfinished features in your trunk / master branch

Page 103: Getting Git Right

Branch per issueFirst:

feature/IRKD-30

stable master branch

isolated feature work

master

Page 104: Getting Git Right

feature/IRKD-30

Branch per issueFirst:

project

issue

branch type

Page 105: Getting Git Right

Typos happne!Tool switching sucks

Page 106: Getting Git Right
Page 107: Getting Git Right
Page 108: Getting Git Right
Page 109: Getting Git Right
Page 110: Getting Git Right
Page 111: Getting Git Right
Page 112: Getting Git Right
Page 113: Getting Git Right
Page 114: Getting Git Right

Atlassian Marketplace1Workflow

SAAS Workflow

Page 115: Getting Git Right

Simplest Workflow

release from here

feature/IRKD-30

feature/IRKD-45

master

Page 116: Getting Git Right

Simplest Workflowrelease from here

feature/IRKD-30

feature/IRKD-45

develop

master

integrate here

Page 117: Getting Git Right

Atlassian Stash2Workflow

Installable software

Page 118: Getting Git Right

Multiple Product Versions

feature/IRKD-30

master

v 1.2

v 1.1

Page 119: Getting Git Right

Multiple Product Versions

master

v 1.2

v 1.1

bugfix/IRKD-41

Page 120: Getting Git Right

Multiple Product Versions

master

v 1.2

v 1.1

bugfix/IRKD-41

Page 121: Getting Git Right

Multiple Product Versions

master

v 1.2

v 1.1

bugfix/IRKD-45

Page 122: Getting Git Right

Multiple Product Versions

master

v 1.2

v 1.1

bugfix/IRKD-45

Page 123: Getting Git Right

Multiple Product Versions

master

v 1.2

v 1.1

bugfix/IRKD-45

boring work

Page 124: Getting Git Right

Automatic merges

https://bitbucket.org/durdn/automatic-merge-hook

with a Git hook

Page 125: Getting Git Right

Automatic mergeswith Stash

Page 126: Getting Git Right

Design your workflow

Nearly everything is possible with

Page 127: Getting Git Right

Good for

Code

stable branches

less error prone

Team

&better understanding

transparency

easier onboarding

Page 128: Getting Git Right

Improving Code Quality

Page 129: Getting Git Right

Have you ever been sitting in a long review session?

Page 130: Getting Git Right

Felt uncomfortable when your code was discussed?

Page 131: Getting Git Right

Code ReviewsSome good reasons to skip

meetings

Page 132: Getting Git Right

Code ReviewsBetter Quality

Learn

Feel Better

Page 133: Getting Git Right

Code ReviewsMake

part of your daily workasynchronouslyless painful

Page 134: Getting Git Right

Pull RequestsMake

part of your daily work

Page 135: Getting Git Right

Part of your daily work

Page 136: Getting Git Right

Part of your daily work

do it before merge

Page 137: Getting Git Right
Page 138: Getting Git Right
Page 139: Getting Git Right
Page 140: Getting Git Right

Discuss

Be respectful!

Page 141: Getting Git Right

Be respectful!

Page 142: Getting Git Right

Be respectful!

Page 143: Getting Git Right

Side by side diffcompare like a pro

Page 144: Getting Git Right

invited reviewers

Page 145: Getting Git Right

invited reviewers

minimum X approvals

Go merge!

fast development

Page 146: Getting Git Right

Minimum of approvals

Page 147: Getting Git Right

Who would be

the best to reviewmy code?

Page 148: Getting Git Right

Auto Suggest Reviewers

Free Add On For

Page 149: Getting Git Right

suggestions why?

Auto Suggest Reviewers

Page 150: Getting Git Right

Auto Suggest Reviewers

committed code to this Pull Request

Suggestions:

contributed files that were modified

Page 151: Getting Git Right

Code ReviewsMake

part of your daily workasynchronouslyless painful

Page 152: Getting Git Right

Protects Code

without slowing you down

Page 153: Getting Git Right

Control access to your repositories

Page 154: Getting Git Right

Permissions for Repositories

Users & GroupsRepositories

Page 155: Getting Git Right

Permissions for Repositories

Projects

Users & Groups

Page 156: Getting Git Right

Permissions for Repositories

Projects

Users & Groups

Page 157: Getting Git Right

Permissions for Repositories

Projects

Users & Groups

Page 158: Getting Git Right

Pure

Permissions for Repositories

Repository Manger

- visual interface - role based

- file system access - SSH - HTTPS

Page 159: Getting Git Right

Less time configuringmore time to code

and waiting

Repository Manger

Page 160: Getting Git Right

People can change code - You control the input

Page 161: Getting Git Right

ForksThe way to allow changes

& protect your code

Page 162: Getting Git Right

Server side clone of the repository

Page 163: Getting Git Right

Server side clone of the repository

Page 164: Getting Git Right

Pull request to contribute changes

Page 165: Getting Git Right

Would Batman allow Robin to fight Joker on his own?

Team

Page 166: Getting Git Right

Branch Permissions

master <deploy on green build to production> branch

everyone can read & branch

with

feature/IRKD-30

master

Page 167: Getting Git Right

master <deploy on green build to production> branch

with

feature/IRKD-30

master

only allowed by trusted devs

Branch Permissions

Page 168: Getting Git Right

withBranch Permissions

Page 169: Getting Git Right

Know your priorities

Security DevSpeed

Page 170: Getting Git Right

Natural Fit

to your existing flow

Page 171: Getting Git Right

There is so much going on in our projects!

Pull Requests

Sprints

Builds

Issues

Branches

Page 172: Getting Git Right

Every line of code starts with

Real Life Problema

Page 173: Getting Git Right

Every line of code starts with

Issuean

Page 174: Getting Git Right

Every line of code should be connected to

Issuean

Page 175: Getting Git Right

Issue Code Git

What most issue tracker do

commit -m "fixes #6"

Page 176: Getting Git Right

But what about the

Feature Branch?

Page 177: Getting Git Right

Issue CodeGit

What some issue trackers do

commit -m "fixes #6"

Page 178: Getting Git Right

Issue CodeGit

What some issue trackers do

branch “feature/IRKD-30“

Page 179: Getting Git Right

Less time tool switchingmore time to code

Page 180: Getting Git Right

Less time answering questionsmore time to code

Page 181: Getting Git Right

Visualize your development

IN PROGRESS

Status People Code

Issue

good old days

Page 182: Getting Git Right

Visualize your development

Issue

Sprint Branch Pull Request

Build

in 2014 style

Page 183: Getting Git Right

Visualize your development

Page 184: Getting Git Right

Visualize your development

Page 185: Getting Git Right

& CI

Page 186: Getting Git Right

experiment on your feature branch

Running builds on feature branches

Page 187: Getting Git Right

experiment on your feature branch

Running builds on feature branches

keep your master branch green

Page 188: Getting Git Right

all active branches are under test

Running builds on feature branches

Page 189: Getting Git Right

Running builds on feature branches

Clone master’s CI config

Page 190: Getting Git Right

You’ll forget to set up the build in your feature branch!

try to remember

Page 191: Getting Git Right

Auto detect branches

Page 192: Getting Git Right

Running builds on feature branches

Jenkins plugin or Git hook

bitbucket.org/tpettersen/git-ci-hooks

Page 193: Getting Git Right

Running builds on feature branches

Build into

Page 194: Getting Git Right

Less time configuringmore time to code

Page 195: Getting Git Right

x developer

times

x push to remote

=lots of builds (waiting)

Page 196: Getting Git Right

Running builds on feature branches

automatically

manuallyfeature/IRKD-30

master

v 1.2

Page 197: Getting Git Right

See what’s going on

Builds

Commits New branches Pull Requests

with

Page 198: Getting Git Right

See what’s going on

Deployment info

with

Page 199: Getting Git Right

See what’s going on

Warnings

with

Page 200: Getting Git Right

More time to codeBetter collaborationDev productivityThe future

Economics

Why Git?

Deliver software faster

Less bugs

Happy customers

Page 201: Getting Git Right

Why Git?

Ship software faster & smarter

Page 202: Getting Git Right

Q & A

Free 30 day trail Free for 5 users Just free!