Real World
Stefan Saasen

Workflows
TODO Show of hands
Picture with hands/lighter/concert
git
Subversion
NO VCS

AT ALL?

you must love pain
Stefan Saasen

Atlassian Stash Development Lead

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

@stefansaasen
You heard

has
Cheap local branching

Full local history
Staging area
Speed

Much faster than svn

Huge community

promine...
ground breaking paradigm
is ground breaking
Workflow building blocks
fork

cheap branching

rebase
powerful merging
distributed

efficient
clone
Can we do a fast
Can we fix a bug for a
specific

RELEASE

HOTFIXrelease?
for the current

?
Can we

BUILD

the current code...
DIFFERENT
PEOPLE
PRODUCTS
CULTURES
DIFFERENT
PEOPLE
PRODUCTS
CULTURES
DIFFERENT
PEOPLE
PRODUCTS
CULTURES

Stash, Bitbucket, JIRA
DIFFERENT
WORKFLOWS
DIFFERENT
PEOPLE
PRODUCTS
CULTURES
We’ll cover:
1

Collaboration model

2

Branching model

3

Practices & Decisions

4

Tooling & Automation
Easy, right?

1

Which collaboration model?
I do my thing

here’s mine, who tells
john?

I do my thing, too

ANARCHY
look ma, a goat!

Fully decentralized
Anarchy
He is cool

Gatekeeper
Blessed repository with
Gatekeeper

To have your work
accepted, talk to him
Dictator
long live the King!

Lieutenants guard
the King

and Lieutenants

Blessed repository
Centralised
Shared common
repository

we share “everything”
More on Collaboration models

atlassian.com/git
+

Enterprise

=

Centralized
Metrics
Issues
Builds
They know where the
code needs to go!

Deployments
2

Which branching model?
Two common Branching Models
1

Continuous Delivery

2

Product Releases
2.2

for Continuous Delivery
Time

feature

staging

master/
production

promoted from staging, can receive hotfixes

master is in production
PR

stagi...
“

Significant branches map to a concept in
the outside world. It may be a past
release, an environment or a role.
Those b...
2.1

for Product Releases
PRJ-123-description
PRJ-123-bug-description

Time

feature
bugfix branch
branches

master

1

Central Repository
Short live...
master

Long running

2.2

PRJ-345-bug-description

Time

bugfix

release
branch

4

Release Branches

5

master is alpha /...
Automatic merges for the win!
Automatic MERGES!

release
branch

2.2

2.1

PRJ-345-bug-description

Time

bugfix

release
branch

master
Placeholder for changes you DON’T want to merge!
release
branch

2.2.1

2.2

2.1

release
branch

2.1.4
2.1.5-SNAPSHOT

What can we do here?

We don’t want to merge
the 2....
git merge --strategy= resolve
git merge --strategy= recursive
git merge --strategy= ours
stable
branch

2.2.1

2.2

2.1

stable
branch

2.1.4
2.1.5-SNAPSHOT

$> git checkout stable-2.2
$> git merge -s ours stabl...
Deep breath, it’s really simple
The secret sauce

The merge protocol
The secret sauce

The merge protocol
When a branch is:

Change flows from
branch to baseline:

Change flows from
baseline to...
The secret sauce

The merge protocol
Release Branch
Never
merge!

Merge
continually

Master

Backport single
changes using...
turbo boost!

3

Practices
What is a Pull Request?
Pull Request
I have some
code here!

Hey I have some code I
want to merge here,
take a look?

Low friction
collaboration

...
Single Repository
vs
Remote Forks
With Forks
Every one has their
remote repository

Full remote copy,
each has one

Integrator, Gatekeeper,
Tech Lead, etc.
Pros of a Single Repo
All feature
branches
available

1

Complete visibility

2

No per Dev remotes required

3

KISS
Forks
Are Great too BTW
FORKING IN
THE

ENTERPRISE
4 Reasons for...

FORKING IN
THE

ENTERPRISE

REASON 1

Great for customizing libraries
and still get bug fixes
FORKING IN
THE

ENTERPRISE

REASON 2

Great for innovation spikes
and maybe add it later
FORKING IN
THE

but still be open for changes

REASON 3

Protecting your components

ENTERPRISE
FORKING IN
THE

ENTERPRISE

REASON 4

Reduce the noise
and keep the overview for huge projects
4

Tooling & Automation
Hooks
“

Hooks are little scripts you can place in
the `$GIT_DIR/hooks` directory to trigger

”

action at certain points.
– git...
Pre

Post
Local

Remote
Local
pre-/post-applypatch
pre-/post-commit

Remote
pre-receive
update

pre-rebase

post-receive

post-checkout

post-upda...
Code Quality
.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 followe...
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...
Get it at:
bitly.com/green-builds
What happens to CI with git?
1

An explosion of branches

2

Performance degradation of build sys

3

Building everything is expensive
1

Automatically build stable and master

2

Manually trigger feature branch builds
In Conclusion: the recipe
Conclusions
Collaboration
Model

Branching
Model
Product
workflow

Centralized

Continuous
delivery
workflow
Merge
protoco...
Thank you for your
attention!
@stefansaasen
ssaasen@atlassian.com
www.atlassian.com
Upcoming SlideShare
Loading in...5
×

JAZOON'13 - Stefan Saasen - Real World Git Workflows

1,335
-1

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,335
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
33
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

JAZOON'13 - Stefan Saasen - Real World Git Workflows

  1. 1. Real World Stefan Saasen Workflows
  2. 2. TODO Show of hands Picture with hands/lighter/concert
  3. 3. git
  4. 4. Subversion
  5. 5. NO VCS AT ALL? you must love pain
  6. 6. Stefan Saasen Atlassian Stash Development Lead I come out nice in pictures, I know :-). @stefansaasen
  7. 7. You heard has Cheap local branching Full local history Staging area Speed Much faster than svn Huge community prominent in Open Source cryptographic integrity Superior Merging Distributed
  8. 8. ground breaking paradigm is ground breaking
  9. 9. Workflow building blocks fork cheap branching rebase powerful merging distributed efficient clone
  10. 10. Can we do a fast Can we fix a bug for a specific RELEASE HOTFIXrelease? for the current ? Can we BUILD the current code ? Is the code for that FEATURE complete? Has everybody REVIEWED ? the code for this feature
  11. 11. DIFFERENT PEOPLE PRODUCTS CULTURES
  12. 12. DIFFERENT PEOPLE PRODUCTS CULTURES
  13. 13. DIFFERENT PEOPLE PRODUCTS CULTURES Stash, Bitbucket, JIRA
  14. 14. DIFFERENT WORKFLOWS DIFFERENT PEOPLE PRODUCTS CULTURES
  15. 15. We’ll cover: 1 Collaboration model 2 Branching model 3 Practices & Decisions 4 Tooling & Automation
  16. 16. Easy, right? 1 Which collaboration model?
  17. 17. I do my thing here’s mine, who tells john? I do my thing, too ANARCHY look ma, a goat! Fully decentralized Anarchy
  18. 18. He is cool Gatekeeper Blessed repository with Gatekeeper To have your work accepted, talk to him
  19. 19. Dictator long live the King! Lieutenants guard the King and Lieutenants Blessed repository
  20. 20. Centralised Shared common repository we share “everything”
  21. 21. More on Collaboration models atlassian.com/git
  22. 22. + Enterprise = Centralized
  23. 23. Metrics Issues Builds They know where the code needs to go! Deployments
  24. 24. 2 Which branching model?
  25. 25. Two common Branching Models 1 Continuous Delivery 2 Product Releases
  26. 26. 2.2 for Continuous Delivery
  27. 27. Time feature staging master/ production promoted from staging, can receive hotfixes master is in production PR staging is the next version new features off staging Hotfix with branch names like: username/ISSUE-KEY-summary
  28. 28. “ Significant branches map to a concept in the outside world. It may be a past release, an environment or a role. Those branches are long-running and stable whereas feature branches are ” short lived and volatile. Me, just making this up.
  29. 29. 2.1 for Product Releases
  30. 30. PRJ-123-description PRJ-123-bug-description Time feature bugfix branch branches master 1 Central Repository Short lived 2 One Branch per Feature 3 One Branch per Bugfix
  31. 31. master Long running 2.2 PRJ-345-bug-description Time bugfix release branch 4 Release Branches 5 master is alpha / RC
  32. 32. Automatic merges for the win!
  33. 33. Automatic MERGES! release branch 2.2 2.1 PRJ-345-bug-description Time bugfix release branch master
  34. 34. Placeholder for changes you DON’T want to merge!
  35. 35. release branch 2.2.1 2.2 2.1 release branch 2.1.4 2.1.5-SNAPSHOT What can we do here? We don’t want to merge the 2.1.x version!
  36. 36. git merge --strategy= resolve
  37. 37. git merge --strategy= recursive
  38. 38. git merge --strategy= ours
  39. 39. stable branch 2.2.1 2.2 2.1 stable branch 2.1.4 2.1.5-SNAPSHOT $> git checkout stable-2.2 $> git merge -s ours stable-2.1 merge commit, content discarded
  40. 40. Deep breath, it’s really simple
  41. 41. The secret sauce The merge protocol
  42. 42. The secret sauce The merge protocol When a branch is: Change flows from branch to baseline: Change flows from baseline to branch: More stable than its baseline Continually Never When code complete Continually Release branch Less stable than its baseline Feature branches Credit: Laura Wingerd - The Flow of change
  43. 43. The secret sauce The merge protocol Release Branch Never merge! Merge continually Master Backport single changes using git cherry-pick
  44. 44. turbo boost! 3 Practices
  45. 45. What is a Pull Request?
  46. 46. Pull Request I have some code here! Hey I have some code I want to merge here, take a look? Low friction collaboration Can I merge it here?
  47. 47. Single Repository vs Remote Forks
  48. 48. With Forks Every one has their remote repository Full remote copy, each has one Integrator, Gatekeeper, Tech Lead, etc.
  49. 49. Pros of a Single Repo All feature branches available 1 Complete visibility 2 No per Dev remotes required 3 KISS
  50. 50. Forks Are Great too BTW
  51. 51. FORKING IN THE ENTERPRISE
  52. 52. 4 Reasons for... FORKING IN THE ENTERPRISE REASON 1 Great for customizing libraries and still get bug fixes
  53. 53. FORKING IN THE ENTERPRISE REASON 2 Great for innovation spikes and maybe add it later
  54. 54. FORKING IN THE but still be open for changes REASON 3 Protecting your components ENTERPRISE
  55. 55. FORKING IN THE ENTERPRISE REASON 4 Reduce the noise and keep the overview for huge projects
  56. 56. 4 Tooling & Automation
  57. 57. Hooks
  58. 58. “ Hooks are little scripts you can place in the `$GIT_DIR/hooks` directory to trigger ” action at certain points. – githooks Documentation
  59. 59. Pre Post
  60. 60. Local Remote
  61. 61. Local pre-/post-applypatch pre-/post-commit Remote pre-receive update pre-rebase post-receive post-checkout post-update post-merge pre-push
  62. 62. Code Quality
  63. 63. .git/hooks/pre-commit
  64. 64. git add -u git commit -m "TEST checkstyle"
  65. 65. Starting audit... /Users/user/[...]/com/atlassian/stash/ web/projects/ProjectController.java: 161:12: 'for' is not followed by whitespace. Audit done. Commit aborted.
  66. 66. Branch from green builds
  67. 67. .git/hooks/post-checkout
  68. 68. $ 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.
  69. 69. Get it at: bitly.com/green-builds
  70. 70. What happens to CI with git?
  71. 71. 1 An explosion of branches 2 Performance degradation of build sys 3 Building everything is expensive
  72. 72. 1 Automatically build stable and master 2 Manually trigger feature branch builds
  73. 73. In Conclusion: the recipe
  74. 74. Conclusions Collaboration Model Branching Model Product workflow Centralized Continuous delivery workflow Merge protocol Adopt Git Practices Embrace PR Single Repo or Forks Automation & CI setup Build automatically, but leave knobs! Hooks, hooks everywhere
  75. 75. Thank you for your attention! @stefansaasen ssaasen@atlassian.com www.atlassian.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×