don't fear the branch - marcus bertrand

Post on 18-Nov-2014

329 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Last Summit, we walked you through a migration from SVN to Git. So now you’re on Git – but what do you do with those branches? Branching in Git is great, but can be intimidating for those coming over from other SCMs. In this talk, you will learn all about branches – how to use them, organize them, and even revert an accidental merge. Embrace those branches and make them work for your team.

TRANSCRIPT

#atlassian

MARCUS BERTRAND • BITBUCKET DEVELOPER • @MARCUSBERTRAND

Don’t Fear the BranchBranching workflows used in Bitbucket and Stash

You should be using branches

W H Y G I T

W H Y Y O U A R E N ’ T

You should be using branches

A N AT O M Y O F A B R A N C H

Too complex

No visibility

Merging is difficult

W H Y G I T

W H Y Y O U A R E N ’ T

You should be using branches

A N AT O M Y O F A B R A N C H

Anatomy of a branch

commit

Anatomy of a branch

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

100644 blob d30480027f7ef61af129b07a21bae8d0ea13eb2a README.md.git/objects/27/4192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b

tree

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

100644 blob d30480027f7ef61af129b07a21bae8d0ea13eb2a README.md.git/objects/27/4192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b

tree

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

100644 blob d30480027f7ef61af129b07a21bae8d0ea13eb2a README.md.git/objects/27/4192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b

tree

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

100644 blob d30480027f7ef61af129b07a21bae8d0ea13eb2a README.md.git/objects/27/4192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b

tree

blob 21^@====== Readme ======

.git/objects/d3/0480027f7ef61af129b07a21bae8d0ea13eb2a

blob

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

100644 blob d30480027f7ef61af129b07a21bae8d0ea13eb2a README.md.git/objects/27/4192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b

tree

blob 21^@====== Readme ======

.git/objects/d3/0480027f7ef61af129b07a21bae8d0ea13eb2a

blob

commit 197^@tree 274192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b author Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408988361 -0700 !Added a readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

100644 blob d30480027f7ef61af129b07a21bae8d0ea13eb2a README.md.git/objects/27/4192fecfeda9ec03d7ab6cd64d5bc22b2cfb8b

tree

blob 21^@====== Readme ======

.git/objects/d3/0480027f7ef61af129b07a21bae8d0ea13eb2a

blob

Anatomy of a branch

4 9 4 2 f 8 7

commit

4 9 4 2 f 8 7

Anatomy of a branch

4 9 4 2 f 8 7

Anatomy of a branch

4942f87f225899b15b9f1c1ebe6a4e61663b8568.git/refs/heads/master

branch

4 9 4 2 f 8 7

Anatomy of a branch

4942f87f225899b15b9f1c1ebe6a4e61663b8568.git/refs/heads/master

branch

ref: refs/heads/master.git/HEAD

head

git checkout -b foo/mybranch

Anatomy of a branch

4942f87f225899b15b9f1c1ebe6a4e61663b8568.git/refs/heads/foo/mybranch

branch

4 9 4 2 f 8 7

Anatomy of a branch

ref: refs/heads/foo/mybranch.git/HEAD

head

Anatomy of a branch

tree 9441d4ef753148ce9cb5aee3966fa6e4f5366be5 parent 4942f87f225899b15b9f1c1ebe6a4e61663b8568 author Marcus Bertrand <mbertrand@atlassian.com> 1408992616 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408992616 -0700 !Made some edits to the readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

Anatomy of a branch

tree 9441d4ef753148ce9cb5aee3966fa6e4f5366be5 parent 4942f87f225899b15b9f1c1ebe6a4e61663b8568 author Marcus Bertrand <mbertrand@atlassian.com> 1408992616 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1408992616 -0700 !Made some edits to the readme

.git/objects/49/42f87f225899b15b9f1c1ebe6a4e61663b8568

commit

bd1174cd0f30fe9be9efdd41dcd56256340f230e.git/refs/heads/foo/mybranch

branch

4 9 4 2 f 8 7

Anatomy of a branch

ref: refs/heads/foo/mybranch.git/HEAD

head

b d 1 1 7 4 c

Anatomy of a branch

4 9 4 2 f 8 7 b d 1 1 7 4 c

m a s t e r f o o / m y b r a n c h

H E A D

git checkout master

Anatomy of a branch

Anatomy of a branch

m a s t e r

f o o / m y b r a n c h

H E A D

Anatomy of a branch

m a s t e r

f o o / m y b r a n c h

Anatomy of a branch

m a s t e r

f o o / m y b r a n c h

H E A D

git merge foo/mybranch

Anatomy of a branch

Anatomy of a branch

f o o / m y b r a n c h

m a s t e r

H E A D

Anatomy of a branch

f o o / m y b r a n c h

M

m a s t e r

H E A D

Anatomy of a branch

f o o / m y b r a n c h

M

Anatomy of a branch

f o o / m y b r a n c h

M

m a s t e r

H E A D

Anatomy of a branch

tree f362c42032aff677c1a09c3f070454df5b411239 parent 49a906f5722ad446a131778cea52e3fda331b706 parent bd1174cd0f30fe9be9efdd41dcd56256340f230e author Marcus Bertrand <mbertrand@atlassian.com> 1409002123 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1409002123 -0700 !Merge branch 'foo/mybranch'

.git/objects/36/80d8c8fd182f97cb0e75045e2fed5c7b7613ed

commit

Anatomy of a branch

tree f362c42032aff677c1a09c3f070454df5b411239 parent 49a906f5722ad446a131778cea52e3fda331b706 parent bd1174cd0f30fe9be9efdd41dcd56256340f230e author Marcus Bertrand <mbertrand@atlassian.com> 1409002123 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1409002123 -0700 !Merge branch 'foo/mybranch'

.git/objects/36/80d8c8fd182f97cb0e75045e2fed5c7b7613ed

commit

Anatomy of a branchH E A D

M

m a s t e r

f o o / m y b r a n c h

W H Y G I T

W H Y Y O U A R E N ’ T

You should be using branches

A N AT O M Y O F A B R A N C H

Every commit is a full copy of the

repository state at that revision

Everything is local

Merging is simple

Better workflows

• 2 Product Managers

• 1 Architect

• 1 Designer

• 2 QA

• 2 Team Leads

• Support, Tech Writing, Product Marketing & more!

• 30 Developers on 3 teams

• Red - Backend

• Blue - Front end

• Enterprise!

The Stash Team

Git Flow

Git Flow

m a s t e r

Git Flow

m a s t e r

f e a t u re / J R A - 1 2 3

Git Flow

m a s t e r

Md e v e l o p

f e a t u re / J R A - 1 2 3

Git Flow

m a s t e r

Md e v e l o p

M

f e a t u re / J R A - 1 2 3

Git Flow

m a s t e r

re l e a s e / 1 . 0

Md e v e l o p

M

f e a t u re / J R A - 1 2 3

Git Flow

m a s t e r

re l e a s e / 1 . 0

Md e v e l o p

M

f e a t u re / J R A - 1 2 3

1 . 0

Git Flow - bugfix

Git Flow - bugfix

re l e a s e / 1 . 0

Git Flow - bugfix

re l e a s e / 1 . 0

b u g f i x / J R A - 2 0 0

Git Flow - bugfix

M

1 . 1

re l e a s e / 1 . 0

b u g f i x / J R A - 2 0 0

Git Flow - bugfix

re l e a s e / 2 . 0 M

2 . 1

M

1 . 1

re l e a s e / 1 . 0

b u g f i x / J R A - 2 0 0

Git Flow - bugfix

m a s t e r M

re l e a s e / 2 . 0 M

2 . 1

M

1 . 1

re l e a s e / 1 . 0

b u g f i x / J R A - 2 0 0

Stash flow

m a s t e r

JIRA

Create Branch

Stash flow

m a s t e r

Stash flow

m a s t e r

f e a t u re / S TA S H D E V 0 7 3 6 9 …

Open a Pull Request

Stash flow

m a s t e r

f e a t u re / S TA S H D E V 0 7 3 6 9 …

M

Wait for the master build

Stash flow

m a s t e r

f e a t u re / S TA S H D E V 0 7 3 6 9 …

M

Stash flow

m a s t e r

f e a t u re / S TA S H D E V 0 7 3 6 9 …

M

re l e a s e / 1 . 0

Release manager

Stash flow

m a s t e r

f e a t u re / S TA S H D E V 0 7 3 6 9 …

Stash flow

m a s t e r

f e a t u re / S TA S H D E V 0 7 3 6 9 …

re l e a s e / 3 . 2

3 . 2

Stash flow

m a s t e r

f e a t u re / S TA S H D E V 0 7 3 6 9 …

re l e a s e / 3 . 2

3 . 2

M

Everyone is happy!

Almost

JIRA

Stash flow

b u g f i x / S TA H D E V- 1 2 3

re l e a s e / 3 . 0 M

re l e a s e / 3 . 1 M

m a s t e r M

Branch configuration

• 2 Product Managers

• 1 Architect

• 1 Designer

• 1QA

• 3 Team Leads

• Support, Tech Writing, Product Marketing & more!

• 1 TL and 3 Operations

• 15 Developers on 2 teams in Austin and San Francisco

• Backend

• Front end

!

The Bitbucket Team

Branch per feature

Branchper bug

Branch per hot fix

Branch

Branch per feature

s t a g i n g M

s t a g e _ 2 0 1 4 0 8 2 7 …

Branch per feature

m b e r t r a n d / B B - 1 2 3

s t a g i n g M

s t a g e _ 2 0 1 4 0 8 2 7 …

M

s t a g e _ 2 0 1 4 0 8 2 6 …

Branch per feature

m b e r t r a n d / B B - 1 2 3

s t a g i n g M

s t a g e _ 2 0 1 4 0 8 2 7 …

M

s t a g e _ 2 0 1 4 0 8 2 6 …

p ro d u c t i o n M

p ro d _ 2 0 1 4 0 8 2 6 …

Branch per feature

m b e r t r a n d / B B - 1 2 3

s t a g i n g M

s t a g e _ 2 0 1 4 0 8 2 7 …

Branch per feature

p ro d u c t i o n

Branch per feature

p ro d u c t i o n

m b e r t r a n d / B B - 1 2 3

Pull request

Comments

Branch per feature

p ro d u c t i o n

s t a g i n g M

m b e r t r a n d / B B - 1 2 3

j m o o / B B - 4 0 0

M

HipChat for Deployments

Branch per bug fix

s t a g i n g M

Branch per bug fix

s t a g i n g M

p ro d u c t i o n M

Branch per bug fix

s t a g i n g M

p ro d u c t i o n M

H O T F I X - B B - 5 0 0

Branch per bug fix

s t a g i n g M

p ro d u c t i o n M

M

H O T F I X - B B - 5 0 0

Branch per bug fix

s t a g i n g M

p ro d u c t i o n M M

M

H O T F I X - B B - 5 0 0

When things go wrong

What did I just merge?

Don’t panic

Unmerge

$ git revert {SHA1}

Mysteries

$ git log --all --stat --graph --parents

$ git show --pretty=raw --stat c102ec5

Branching==safety

Git branching==Freedom

Small changes==great success

atlassian.com/git

Thank you!

MARCUS BERTRAND • BITBUCKET DEVELOPER • @MARCUSBERTRAND

top related