Getting Git Right

Post on 08-Sep-2014

36 views 4 download

Tags:

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 of Getting Git Right

his smile is contagious :D

Nicola PaolucciDeveloper Advocate / Git Evangelist

Sven PetersAtlassian Ambassador

@svenpetsvenpet.com

@durdndurdn.com

checkout his stare :D

Productive TeamsHappy Developers35 min 35 min

Who knows

?

?

doesn’t

Who know

Facts

300 Developer

Facts

750 Nerds

Facts

working on 9 products

Facts

on 4 Continents

SoftwareWe

or in just 3 words

SoftwareWe Teams

really small team

they know what’s going on!

Let’s do it!

Great idea!

Productivity++

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?

Productivity??

we’re not alone

Is it profitable?!

When is it done?!

is a

Devel ping S ftware

S cial Challenge

Tools

efficient collaboration

transparent dev processshare knowledge

fast feedback

Tools

happy developers & productive teams Ship software

faster & smarter

Ship software faster & smarter

happy developers & productive teams

Our journey to

Great!

+Be the change

you seek

Technical side Human side

Technical Side: We’ve got you covered

Scripts Documentation

S V NG I T

atlassian.com/git/migration

Technical Side: We’ve got you covered

identifying champions staff training not everyone was happy

Human Side: Most important aspect!

At the end we migrated…

200+11

21,00047,228 commits

filescommittersyear’s work

and that is just for JIRA

The Numbers

what is the industry doing?

Git is on the rise

15%

38%

from 2011 to 2013Source: RedMonk Git Survey 2013

Git will continue to grow!

63 %

37 %

December 2015

Git

CVS + SVN

Source: Atlassian Git Survey 2013

Git works for the enterprise!

60%100+ developers

1,000+ employees

Source: Atlassian Git Survey 2013

Git works for the enterprise!

27%

69%

use the cloud

develop on-premise

Source: CollabNet Git Survey 2013

Git means fast releases

Git

SVN CVS

mainly daily - weekly

mainly monthly

Source: Atlassian Git Survey 2013

Better code with Git

Code Reviewsare great for the code and the team!

Better code with Git

Code Reviews when using GIT

+15% more

thank you Pull Requests!

Source: Atlassian Git Survey 2013

is just a tool!

How do you use ?

Happier Developerwith

Be a

Nicola Paolucci!Developer Advocate / Evangelist

Sven Peters!Ambassador

March 2014!with! and!

Time machine without paradoxes?

Explore & Understand

1

3

Speed, Speed, Speed

Control and Assemble4

Why does make you happy?

2 Freedom & Safety

1

Fast is the new Black

Speed, speed, Speed

Staying in the flow makes you happy and your

manager happy…

Everything is local

Except push & pull

Written in C by Linux kernel and filesystem

developers

Read: fast :D

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

2 Freedom & Safety

Fast Context Switching

Freedom to innovatewith

Feature Branching

Feature Branching

Feature branches: local

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

Feature branches: published (remote)

git push origin new-branch pushes a local branch remotely

git stash is awesomeIt’s a way to

temporarily save your work on a stack

So if your boss comes screaming at your desk

git stash create a patch without a hassle

stash and branch FTW

trick close to my heart

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

Safety

Losing work is very hard

very very

maybe your git server crashed and the hd is

corrupted?… no problem

Redundancy, every developer has a clone

Chain of unlosability (I coined a new word!)

Recover a file

git checkout file-name

Recover a commit

git checkout sha-1

git checkout ref (branch/tag)

or

Print file as in branch

git show branch:path/to/file

can be any ref

find a deleted method

git log -S<string> search through all history

When all is lost, use the reflog

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

HEAD has been

garbage collected every

30 days

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

Explore & Understand 3

Inspect Everything

= history superpowers

Hard Questions to git logAsk

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

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

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

Where is that constant?

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

away

have I merged this?

git branch --no-merged lists branches not merged

git branch --merged lists branches already merged

Control and Assemble4

Why merge is awesome !

with

What is a merge?

Merge commit

master

feature

merges keep the context of the

feature’s commits

git knows the ancestry

1

2

The merge is local

powerful merge strategies3

merge is better in git

merge becomes a non-event

In most cases

rebase: Fiddle with safety belts on

master

feature

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

commits, one by one, on top of a branch

feature

master

What is a rebase?preserving the order

of change-sets

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

CUSTOMARY WARNING!

rebase rewrites history!

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

One more thing…

is great for dating

git dating fake!

Explore & Understand

1

3

Speed, Speed, Speed

Control and Assemble4

Why does make you happy?

2 Freedom & Safety

Happy Developerwith

A

Productive Team withA

Improving Code Quality

1

2

Efficient Workflows

Protects Code3

Why makes a team great!

4 Natural Fit

Efficient Workflows

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 ?

Git workflow?What’s the best

We don’t know!

+ different teams+ different products

different cultures

= different workflows

Git workflow?What’s the best

DesignWorkflows

your own

Issues Code

Issues Code

#30

#45#45

#30

Can’t be released right now

Unfinished features in your trunk / master branch

Branch per issueFirst:

feature/IRKD-30

stable master branch

isolated feature work

master

feature/IRKD-30

Branch per issueFirst:

project

issue

branch type

Typos happne!Tool switching sucks

Atlassian Marketplace1Workflow

SAAS Workflow

Simplest Workflow

release from here

feature/IRKD-30

feature/IRKD-45

master

Simplest Workflowrelease from here

feature/IRKD-30

feature/IRKD-45

develop

master

integrate here

Atlassian Stash2Workflow

Installable software

Multiple Product Versions

feature/IRKD-30

master

v 1.2

v 1.1

Multiple Product Versions

master

v 1.2

v 1.1

bugfix/IRKD-41

Multiple Product Versions

master

v 1.2

v 1.1

bugfix/IRKD-41

Multiple Product Versions

master

v 1.2

v 1.1

bugfix/IRKD-45

Multiple Product Versions

master

v 1.2

v 1.1

bugfix/IRKD-45

Multiple Product Versions

master

v 1.2

v 1.1

bugfix/IRKD-45

boring work

Automatic merges

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

with a Git hook

Automatic mergeswith Stash

Design your workflow

Nearly everything is possible with

Good for

Code

stable branches

less error prone

Team

&better understanding

transparency

easier onboarding

Improving Code Quality

Have you ever been sitting in a long review session?

Felt uncomfortable when your code was discussed?

Code ReviewsSome good reasons to skip

meetings

Code ReviewsBetter Quality

Learn

Feel Better

Code ReviewsMake

part of your daily workasynchronouslyless painful

Pull RequestsMake

part of your daily work

Part of your daily work

Part of your daily work

do it before merge

Discuss

Be respectful!

Be respectful!

Be respectful!

Side by side diffcompare like a pro

invited reviewers

invited reviewers

minimum X approvals

Go merge!

fast development

Minimum of approvals

Who would be

the best to reviewmy code?

Auto Suggest Reviewers

Free Add On For

suggestions why?

Auto Suggest Reviewers

Auto Suggest Reviewers

committed code to this Pull Request

Suggestions:

contributed files that were modified

Code ReviewsMake

part of your daily workasynchronouslyless painful

Protects Code

without slowing you down

Control access to your repositories

Permissions for Repositories

Users & GroupsRepositories

Permissions for Repositories

Projects

Users & Groups

Permissions for Repositories

Projects

Users & Groups

Permissions for Repositories

Projects

Users & Groups

Pure

Permissions for Repositories

Repository Manger

- visual interface - role based

- file system access - SSH - HTTPS

Less time configuringmore time to code

and waiting

Repository Manger

People can change code - You control the input

ForksThe way to allow changes

& protect your code

Server side clone of the repository

Server side clone of the repository

Pull request to contribute changes

Would Batman allow Robin to fight Joker on his own?

Team

Branch Permissions

master <deploy on green build to production> branch

everyone can read & branch

with

feature/IRKD-30

master

master <deploy on green build to production> branch

with

feature/IRKD-30

master

only allowed by trusted devs

Branch Permissions

withBranch Permissions

Know your priorities

Security DevSpeed

Natural Fit

to your existing flow

There is so much going on in our projects!

Pull Requests

Sprints

Builds

Issues

Branches

Every line of code starts with

Real Life Problema

Every line of code starts with

Issuean

Every line of code should be connected to

Issuean

Issue Code Git

What most issue tracker do

commit -m "fixes #6"

But what about the

Feature Branch?

Issue CodeGit

What some issue trackers do

commit -m "fixes #6"

Issue CodeGit

What some issue trackers do

branch “feature/IRKD-30“

Less time tool switchingmore time to code

Less time answering questionsmore time to code

Visualize your development

IN PROGRESS

Status People Code

Issue

good old days

Visualize your development

Issue

Sprint Branch Pull Request

Build

in 2014 style

Visualize your development

Visualize your development

& CI

experiment on your feature branch

Running builds on feature branches

experiment on your feature branch

Running builds on feature branches

keep your master branch green

all active branches are under test

Running builds on feature branches

Running builds on feature branches

Clone master’s CI config

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

try to remember

Auto detect branches

Running builds on feature branches

Jenkins plugin or Git hook

bitbucket.org/tpettersen/git-ci-hooks

Running builds on feature branches

Build into

Less time configuringmore time to code

x developer

times

x push to remote

=lots of builds (waiting)

Running builds on feature branches

automatically

manuallyfeature/IRKD-30

master

v 1.2

See what’s going on

Builds

Commits New branches Pull Requests

with

See what’s going on

Deployment info

with

See what’s going on

Warnings

with

More time to codeBetter collaborationDev productivityThe future

Economics

Why Git?

Deliver software faster

Less bugs

Happy customers

Why Git?

Ship software faster & smarter

Q & A

Free 30 day trail Free for 5 users Just free!