Real world Git workflows TODO Show of hands Picture with - - PowerPoint PPT Presentation

real world git workflows
SMART_READER_LITE
LIVE PREVIEW

Real world Git workflows TODO Show of hands Picture with - - PowerPoint PPT Presentation

Real world Git workflows TODO Show of hands Picture with hands/lighter/concert Stefan Saasen Atlassian Stash Development Lead Stefan Saasen Atlassian Stash Development Lead @stefansaasen You heard is on the rise 38% 15% from 2011


slide-1
SLIDE 1
slide-2
SLIDE 2

Real world Git workflows

slide-3
SLIDE 3

TODO Show of hands

  • Picture with hands/lighter/concert
slide-4
SLIDE 4

Stefan Saasen

Atlassian Stash Development Lead

slide-5
SLIDE 5

Stefan Saasen

Atlassian Stash Development Lead

@stefansaasen

slide-6
SLIDE 6

15% 38%

from 2011 to 2013

Source: RedMonk Git Survey 2013

You heard is on the rise

slide-7
SLIDE 7

Cheap local branching Full local history Speed Staging area prominent in Open Source Huge community

You heard has

Superior Merging Much faster than svn Distributed cryptographic integrity

slide-8
SLIDE 8

We’ll cover:

slide-9
SLIDE 9

1

Collaboration model We’ll cover:

slide-10
SLIDE 10

1 2

Collaboration model We’ll cover: Branching model

slide-11
SLIDE 11

1

Practices

2 3

Collaboration model We’ll cover: Branching model

slide-12
SLIDE 12

Which collaboration model?

1

slide-13
SLIDE 13

Slide Title

slide-14
SLIDE 14

Fully decentralized Anarchy

ANARCHY

slide-15
SLIDE 15

Fully decentralized Anarchy

I do my thing I do my thing, too

ANARCHY

here’ s mine, who tells john? look ma, a goat!

slide-16
SLIDE 16

Blessed repository with Gatekeeper

Gatekeeper

slide-17
SLIDE 17

Blessed repository with Gatekeeper

He is cool

Gatekeeper

To have your work accepted, talk to him

slide-18
SLIDE 18

and Lieutenants

Dictator

slide-19
SLIDE 19

and Lieutenants

Dictator

long live the King! Lieutenants guard the King Blessed repository

slide-20
SLIDE 20

Shared common repository

Centralised

slide-21
SLIDE 21

Shared common repository

we share “everything”

Centralised

slide-22
SLIDE 22

+

slide-23
SLIDE 23

+

Enterprise

slide-24
SLIDE 24

+

=

Centralized

Enterprise

slide-25
SLIDE 25
slide-26
SLIDE 26

Builds Metrics Issues Deployments

slide-27
SLIDE 27

Builds Metrics Issues Deployments

They know where the code needs to go!

slide-28
SLIDE 28

Which branching model?

slide-29
SLIDE 29

Which branching model?

2

slide-30
SLIDE 30
slide-31
SLIDE 31

upcoming Release ? Can we still fix a bug for the

slide-32
SLIDE 32

upcoming Release ? Can we still fix a bug for the

Feature

Is the code for that complete?

slide-33
SLIDE 33

upcoming Release ? Can we still fix a bug for the

Feature

Is the code for that complete? for the current version?

Hotfix

How do we do a

slide-34
SLIDE 34

upcoming Release ? Can we still fix a bug for the

Feature

Is the code for that complete? for the current version?

Hotfix

How do we do a

Reviewed

Has everyone the code for this feature ?

slide-35
SLIDE 35

Git workflow? What’s the best

slide-36
SLIDE 36

Git workflow? What’s the best

We don’ t know!

slide-37
SLIDE 37

different cultures

Git workflow? What’s the best

slide-38
SLIDE 38

+ different products different cultures

Git workflow? What’s the best

slide-39
SLIDE 39

+ different teams + different products different cultures

Git workflow? What’s the best

slide-40
SLIDE 40

+ different teams + different products different cultures = different workflows

Git workflow? What’s the best

slide-41
SLIDE 41

Design Workflows

your own

slide-42
SLIDE 42
  • 1. Single branch workflow - aka trunk
slide-43
SLIDE 43

Committing locally

Master

Local Repository

slide-44
SLIDE 44

Committing locally

Master

Local Repository

slide-45
SLIDE 45

Central repository has updates

Central Repository Local Repository

Master Master

slide-46
SLIDE 46

Getting updates via rebase

Central Repository Local Repository

Master Master

slide-47
SLIDE 47

Getting updates via rebase

Central Repository Local Repository

Master Master

slide-48
SLIDE 48
  • 2. Feature branching workflow
slide-49
SLIDE 49

Creating a branch

master

slide-50
SLIDE 50

master Feature #1

Creating a branch

slide-51
SLIDE 51

Adding changes

master Feature #1

slide-52
SLIDE 52

Merge

master Feature #1

m

slide-53
SLIDE 53

Working on features in parallel

master Feature #1 Feature #2

m

slide-54
SLIDE 54

Working on features in parallel

master Feature #1 Feature #2

m

slide-55
SLIDE 55

Suboptimal way

master Feature #1 Feature #2

m m

a v

  • i

d t h i s i f p

  • s

s i b l e

slide-56
SLIDE 56

master Feature #1 Feature #2

m m m

a v

  • i

d t h i s i f p

  • s

s i b l e Suboptimal way

slide-57
SLIDE 57

A better way using rebase

master Feature #1 Feature #2

m

slide-58
SLIDE 58

Working on features in parallel

master Feature #1 Feature #2

m m m

slide-59
SLIDE 59

Working on features in parallel

master Feature #1 Feature #2

m m m

slide-60
SLIDE 60

Working on features in parallel

master Feature #1 Feature #2

m m m

  • Always with local branches
slide-61
SLIDE 61

Working on features in parallel

master Feature #1 Feature #2

m m m

  • Always with local branches
  • With shared branches: After review, before merging
slide-62
SLIDE 62

Working on features in parallel

master Feature #1 Feature #2

m m m

  • Always with local branches
  • With shared branches: After review, before merging
  • Mostly a non-issue for short lived branches when

updates from master are not required

slide-63
SLIDE 63
  • 3. Continuous delivery workflow
slide-64
SLIDE 64
slide-65
SLIDE 65

master is in production

1

slide-66
SLIDE 66

master is in production

1

promoted from staging, can receive hot-fixes

slide-67
SLIDE 67

master is in production

1

staging is the next version

2

promoted from staging, can receive hot-fixes

slide-68
SLIDE 68

master is in production

1

staging is the next version new features off staging

2 3

promoted from staging, can receive hot-fixes

slide-69
SLIDE 69

master is in production

1

staging is the next version new features off staging

2 3

with branch names like: username/ISSUE-KEY-summary promoted from staging, can receive hot-fixes

slide-70
SLIDE 70

staging master

  • 3. Continuous delivery workflow

feature-1

m

slide-71
SLIDE 71

staging master feature-2

  • 3. Continuous delivery workflow

m

feature-1

m m

slide-72
SLIDE 72

staging master feature-2

  • 3. Continuous delivery workflow

m

feature-1

m m m

slide-73
SLIDE 73

staging master feature-2

  • 3. Continuous delivery workflow

m

feature-1

m m R H m

slide-74
SLIDE 74

staging master feature-2

  • 3. Continuous delivery workflow

m

feature-1

m m R H

release to production = merge master

In Production

m

slide-75
SLIDE 75

staging master feature-2

  • 3. Continuous delivery workflow

m

feature-1

m m R H

  • nly merges

release to production = merge master

In Production

m

slide-76
SLIDE 76
  • 4. Product releases workflow
slide-77
SLIDE 77
slide-78
SLIDE 78
  • ne branch per feature

1

slide-79
SLIDE 79
  • ne branch per feature

1

  • ne branch per bugfix

2

slide-80
SLIDE 80
  • ne branch per feature

1

  • ne branch per bugfix

long running stable branches

2 3

slide-81
SLIDE 81
  • ne branch per feature

1

  • ne branch per bugfix

long running stable branches

2 3

master is alpha/RC status

4

slide-82
SLIDE 82

it’s just a normal branching workflow…

master feature-1 feature-2

slide-83
SLIDE 83

with long running release branches

master 2.2 2.1 bugfix feature-1 feature-2

slide-84
SLIDE 84

Master 2.2

Bugfix Merge

2.1 Bugfix

slide-85
SLIDE 85

Master 2.2

Merge into 2.1

2.1 Bugfix

slide-86
SLIDE 86

Master 2.2

Merge into 2.2

2.1 Bugfix

slide-87
SLIDE 87

Master 2.2

Merge into Master

2.1 Bugfix

slide-88
SLIDE 88

Master 2.2 2.1 Bugfix

Automatically merging release branches

slide-89
SLIDE 89

Master 2.2 2.1 Bugfix

Automatically merging release branches

Automatic MERGES!

slide-90
SLIDE 90
slide-91
SLIDE 91

2.2 2.1 Bugfix

Automatically merging release branches

2.1.5-SNAPSHOT 2.1.4 We don’ t want to merge the 2.1.x version!

slide-92
SLIDE 92
slide-93
SLIDE 93

git merge --strategy= resolve

slide-94
SLIDE 94

git merge --strategy= recursive

slide-95
SLIDE 95

git merge --strategy=

slide-96
SLIDE 96

git merge --strategy= ours

slide-97
SLIDE 97

2.2 2.1 Bugfix

Automatically merging release branches

2.1.5-SNAPSHOT 2.1.4 $> git checkout stable-2.2 $> git merge -s ours stable-2.1

slide-98
SLIDE 98

2.2 2.1 Bugfix

Automatically merging release branches

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

slide-99
SLIDE 99
  • verall picture

master 2.2 2.1 bugfix feature-1 feature-2

slide-100
SLIDE 100

Deep breath, it’s really simple

slide-101
SLIDE 101

The merge protocol

The secret sauce

slide-102
SLIDE 102

The merge protocol

The secret sauce

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

slide-103
SLIDE 103

The merge protocol

The secret sauce

When a branch is: Change flows from 
 branch to baseline: Change flows from baseline to branch: More stable than its baseline

slide-104
SLIDE 104

The merge protocol

The secret sauce

When a branch is: Change flows from 
 branch to baseline: Change flows from baseline to branch: More stable than its baseline

Release branch

slide-105
SLIDE 105

The merge protocol

The secret sauce

When a branch is: Change flows from 
 branch to baseline: Change flows from baseline to branch: More stable than its baseline Continually

Release branch

slide-106
SLIDE 106

The merge protocol

The secret sauce

When a branch is: Change flows from 
 branch to baseline: Change flows from baseline to branch: More stable than its baseline Continually Never

Release branch

slide-107
SLIDE 107

The merge protocol

The secret sauce

When a branch is: Change flows from 
 branch to baseline: Change flows from baseline to branch: More stable than its baseline Continually Never Less stable than its baseline

Release branch

slide-108
SLIDE 108

The merge protocol

The secret sauce

When a branch is: Change flows from 
 branch to baseline: Change flows from baseline to branch: More stable than its baseline Continually Never Less stable than its baseline

Release branch Feature branches

slide-109
SLIDE 109

The merge protocol

The secret sauce

When a branch is: Change flows from 
 branch to baseline: Change flows from baseline to branch: More stable than its baseline Continually Never Less stable than its baseline When code complete

Release branch Feature branches

slide-110
SLIDE 110

The merge protocol

The secret sauce

When a branch is: Change flows from 
 branch to baseline: Change flows from baseline to branch: More stable than its baseline Continually Never Less stable than its baseline When code complete Continually

Release branch Feature branches

slide-111
SLIDE 111

The merge protocol

The secret sauce

When a branch is: Change flows from 
 branch to baseline: Change flows from baseline to branch: More stable than its baseline Continually Never Less stable than its baseline When code complete Continually

Release branch Feature branches

Credit: Laura Wingerd - The Flow of change

slide-112
SLIDE 112

The merge protocol

The secret sauce

Release Branch Master

http:/ /bit.ly/branch-based-workflows

slide-113
SLIDE 113

The merge protocol

The secret sauce

Release Branch Master

Merge continually http:/ /bit.ly/branch-based-workflows

slide-114
SLIDE 114

The merge protocol

The secret sauce

Release Branch Master

Merge continually Never merge! http:/ /bit.ly/branch-based-workflows

slide-115
SLIDE 115

The merge protocol

The secret sauce

Release Branch Master

Merge continually Backport single changes using git cherry-pick Never merge! http:/ /bit.ly/branch-based-workflows

slide-116
SLIDE 116

http:/ /bit.ly/branch-based-workflows

The merge protocol

The secret sauce

slide-117
SLIDE 117

atlassian.com/git

More on git workflows

slide-118
SLIDE 118

Practices

slide-119
SLIDE 119

Practices

4

slide-120
SLIDE 120

What happens to CI with git?

slide-121
SLIDE 121

experiment on your feature branch

Running builds on feature branches

slide-122
SLIDE 122

experiment on your feature branch

Running builds on feature branches

slide-123
SLIDE 123

experiment on your feature branch

Running builds on feature branches

slide-124
SLIDE 124

experiment on your feature branch

Running builds on feature branches

keep your master branch green

slide-125
SLIDE 125

x developer

slide-126
SLIDE 126

x developer

times

x push to remote

slide-127
SLIDE 127

x developer

times

x push to remote =

lots of builds (waiting)

slide-128
SLIDE 128

Running builds on feature branches

automatically manually

feature/IRKD-30 master v 1.2

slide-129
SLIDE 129

Code Reviews

slide-130
SLIDE 130

Code Reviews

Better Quality Learn Find errors

slide-131
SLIDE 131

Pull Requests

part of your daily workflow

slide-132
SLIDE 132

Part of your daily work

slide-133
SLIDE 133

Part of your daily work

Pull Request

Discuss

slide-134
SLIDE 134

Part of your daily work

Pull Request

Discuss

slide-135
SLIDE 135

In Conclusion: the recipe

slide-136
SLIDE 136
  • Branching

Model Adopt Git Practices

  • Collaboration

Model

slide-137
SLIDE 137
  • Branching

Model Adopt Git Practices

  • Collaboration

Model Centralized

slide-138
SLIDE 138
  • Branching

Model Adopt Git Practices

  • Product

workflow

  • Collaboration

Model Centralized

slide-139
SLIDE 139
  • Branching

Model Adopt Git Practices

  • Product

workflow Continuous delivery workflow

  • Collaboration

Model Centralized

slide-140
SLIDE 140
  • Branching

Model Adopt Git Practices

  • Product

workflow Continuous delivery workflow

  • Collaboration

Model Centralized Merge protocol

slide-141
SLIDE 141
  • Branching

Model Adopt Git Practices

  • Product

workflow Continuous delivery workflow Build automatically, but leave knobs!

  • Collaboration

Model Centralized Merge protocol

slide-142
SLIDE 142
  • Branching

Model Adopt Git Practices

  • Product

workflow Continuous delivery workflow Embrace PR Build automatically, but leave knobs!

  • Collaboration

Model Centralized Merge protocol

slide-143
SLIDE 143
  • Thank you for your
  • attention!
  • @stefansaasen
  • ssaasen@atlassian.com
  • www.atlassian.com
slide-144
SLIDE 144

http://www.flickr.com/photos/45143319@N00/3888895871/ http://www.flickr.com/photos/40145521@N00/460270581/ http://www.flickr.com/photos/41864721@N00/4647696349 http://www.flickr.com/photos48889052497@N01/12613483263/ http://www.flickr.com/photos/30928442@N08/4766664095/ http://www.flickr.com/photos/marfis75/3272079115/

Credits