Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
The business case for GitThe ultimate workflow
Tim Pettersen • Developer Provocateur • Atlassian •
@kannonboy
Tim Pettersen
Developer Provocateur
@kannonboy
Who knows
?
Facts
800+ Developers
1800+ Nerds
Facts
working on 9+ products
Facts
Tools
happy developers &
productive teams Ship software
faster & smarter
Ship software
faster & smarter
happy developers &
productive teams
WHY GIT?
THE ULTIMATE WORKFLOW
PULL REQUESTS
INTERMISSION
The ultimate workflow
MERGE STRATEGIES
CONTINUOUS INTEGRATION
CO...
Why
VCS marketshare 2015
Source: Black Duck https://www.openhub.net/repositories/compare
9% 47% 38% 2%
VCS trends (since
2010)
-16% -13%
+27% +0.75%
Source: Red Monk http://redmonk.com/sogrady/2013/12/19/dvcs-and-git-2013/
0
10
20
30
40
Daily Weekly Monthly Quarterly Yearly
git centralized
Source: Atlassian Git Survey 2013
release speed: git v...
Speed, speed, Speed
Everything is local
C by Linux kernel and filesystem
But what if my repo is big?
446k lines of code added
1
3
The Linux kernel 3.13 release had 15+
million LOC
1,339 contribut...
atlassian.com/git
Migrating soon?
The Ultimate
Workflow
Branching
upcoming Release?
Can we still fix a bug for the
Feature
Is the code for that
complete?
for the current version?
HotfixHow...
Git workflow?
What’s the best
I don’t know!
+ different teams
+ different products
different cultures
= different workflows
Git workflow?
What’s the best
Design
Workflows
your own
Issues Code
JIRA-456
JIRA-123
JIRA-123
JIRA-456
Issues Code
Broken
Builds
Everybody is affected
Photo: Resolute
Code freezes suck
Photo: LA (Phot) Kelly Whybrow / MOD
Code
Freeze
JIRA-456
JIRA-123
Linear workflow
Can’t be released right now
Half-baked
Features
Code freezes suck
Photo: LA (Phot) Kelly Whybrow / MOD
Code
Freeze
Photo: Jason Auch
Code
Freeze
Idle developer
Another
JIRA-456
JIRA-123
Linear workflow
feature/JIRA-123
stable master branch
isolated feature work
master
Branching workflow
feature/JIRA-30-user-
avatars
branch type
issue key
description
Branch per issue
bugfix/JIRA-31-oauth-npe
branch type
issue key
description
Branch per issue
hotfix/JIRA-32-wtf-ie8-srsly
branch type
issue key
description
Branch per issue
per
Branch all the things
Branch featurebugdoc change
Why branch?
• Isolation
• Stability
• Traceability
Traceability
What’s shipping?
git branch --merged
git branch --no-merged
What’s left to do?
Atlassian Bitbucket
Workflow
SaaS Workflow
feature/JIRA-123
master
Integration Failures
feature/JIRA-456
stable master branchUn
developmaster
feature/JIRA-123
Integration Failures
feature/JIRA-456
develop
master
feature/JIRA-123
Integration Failures
feature/JIRA-456
Continuously
deployed
to “Staging”
Continuously
depl...
develop
master
Hotfixes
develop
master
Hotfixes
develop
Hotfixes
hotfix/JIRA-1911
master
Atlassian Stash
Workflow
Mobile, desktop &
on-premise server
software
Multiple Product Versions
feature/JIRA-30
master
v 1.2
v 1.1
master
v 1.2
v 1.1
bugfix/JIRA-41
Multiple Product Versions
master
v 1.2
v 1.1
bugfix/JIRA-41
Multiple Product Versions
master
v 1.2
v 1.1
bugfix/JIRA-41
Multiple Product Versions
master
v 1.2
v 1.1
bugfix/JIRA-45
Multiple Product Versions
master
v 1.2
v 1.1
bugfix/JIRA-45
Multiple Product Versions
master
v 1.2
v 1.1
bugfix/JIRA-45
Multiple Product Versions
master
v 1.2
v 1.1
bugfix/JIRA-45
Multiple Product Versions
master
v 1.2
v 1.1
bugfix/JIRA-45
boring work
Multiple Product Versions
Automatic merges
with Stash
Merge Strategies
What is a merge?
Merge commit
develop
feature
merges keep the
context of the feature’s
commits
git rebase:
Rewrite history safely
feature
develop
What is a rebase?
It’s a way to replay
commits, one by one,
on top of a branch
develop
feature
What is a rebase?
preserving the order of
commits
What is an
--interactive rebase?
It’s a way to replay
commits, one by one,
deciding interactively
what to do with each
rew...
CUSTOMARY
WARNING!
rebase rewrites history!
Treat this power with great
care. Only rewrite history of
local branches or…
Rewriting history
master
alice/master
bob/master
Original AND rewritten commit are now in history!
DON’T REWRITE
PUBLISHED HISTORY
(don’t push --force to a shared branch)
feature/JIRA-123
master
Merge Commit
feature/JIRA-123
master
Rebase (Fast-forward)
feature/JIRA-123
master
Rebase (Squash)
Merge Commit Rebase (FF) Rebase (Squash)
No merge commits
Verbose history
Easy to read
Can be more difficult
to trace chan...
Intermission!
Trivia!
Which hashing algorithm
does git use for generating
commit IDs?
SHA-1 MD5
The git checkout command
can be used to check out an
existing branch.
True False
The git checkout command can
be used to create a new branch.
True False
The git checkout command can
be used to check out a file.
True False
The git checkout command can
be used to create a new tag.
FalseTrue
What is the purpose of the
.gitignore file?
ignore files
with certain
names
ignore
different line
endings
The git DAG (which stores
refs, trees and blobs)
stands for..
Directed
Acyclic
Graph
Data
Agnostic
Graph
In git, what is a merge with
more than two parents called?
OctopusHydra
Creating a new branch from a 40
megabyte working copy will take
how much disk space?
40 bytes 40 megabytes
What is a shallow clone?
a clone with
limited
history
a clone with no
submodules
What is a bare clone?
a clone with
no working
directory
a clone with
no branches
or tags
The git 1.0.0 release was tagged
in which year?
2005 2006
Which flag can you pass to the
git merge command to make it
try harder to detect moved
segments within changed files?
--pa...
The first git commit message by
Linus Torvalds reads: “Initial
revision of git…
…the information
manager from
hell”
…bye-b...
What command is executed on a
git server when you push
changes over SSH?
git-receive-pack git-upload-pack
It is possible to have more than one
root commit in a git repository.
True False
What hexadecimal character
does the SHA of the root commit
of the git project end with?
0 1
TIE-BREAKER
What does this SHA refer to?
4b825dc642cb6eb9a060e54bf8d69288fbee4904
an empty
tree
an empty
blob
Code
Review
Code review: why?
• Better code - this one is obvious
• Teach your co-workers - and learn from them
• Lower your bus facto...
Code review
Pull requests
Pull requests
Pull requests
review before merging
Peer Review
10 tips for better pull
requests
bit.ly/10-pr-tips
(from Mark Seemann a.k.a @ploeh)
1. make it small
bit.ly/10-pr-tips
2. do one thing
4. avoid reformatting
bit.ly/10-pr-tips
3. watch your line width
5. make sure the code builds
bit.ly/10-pr-tips
6. make sure the tests
pass
7. add
tests
8. document your
reasoning
bit.ly/10-pr-tips
9. write well
obvious
code
code
comments
commit
message
PR
comments> > >
10. avoid thrashing
bit.ly/10-pr-tips
11. avoid flamewars
Photo: MANOJTV
12. set a team policy
Continuous
Integration
automatically triggered
Building branches
maste
r
always build master
Is the branch green?
Confounding build breakages
master
Confounding build breakages
bugfix/JRA-1
master
Is the branch green?
Collaborate
Photo: Photographer's Mate 3rd Class Eric S. Garst
better
Working with
contractors?
Circle of
Trust
Photo: Aljaz Zajc
Strangers on the
internet
Contractors
Interns
Other
product
teams
Support
Core dev
team
Circle of
Trust
Collaborating with SVN
Core dev
team
Everyone
else
emailing patches
repository tarballs
hell-ish conflicts
Collaborating with forks
Everyone
else
Core dev
team Changes
automatically
synchronize
downstream
.. but must
be reviewed ...
feature/*
Mentoring with branches
Senior
developers
Junior
developers
maste
r
Strangers on the
internet
Interns
Other
product
teams
Support
Core dev
team
Contractors
Why
Why
Git workflows
for teams
Extensions
&
Integrations
Scalability
Why ?
Git workflow for teams
feature/STASH-123
master
Forking
Branching
vs
feature/STASH-123
master
Git workflow for teams
X reviewers approved?
Y builds passed?
All tasks complete?
feature/STASH-123
master
Git workflow for teams
Pull request merge checks
Repository hooks
Branch permissions
feature/STASH-123
master
Git workflow for teams
Pull request merge checks
Repository hooks
Branch permissions
Flexible &
E...
Powerful integrations
Powerful integrations
• Full Java API
• Repository Hooks
• Merge Checks
• User Interface
• REST end-points
• Filetype renderers
• SSH commands
S...
insert /rest/api/latestRESTful APIs
RESTful APIs insert /rest/api/latest
Scalability
Request throttling
Request queuing
Scalability
Response Caching
Scalability
Clustering
Scalability
Git workflows
for teams
Extensions
&
Integrations
Scalability
Why ?
BIG thanks to
your local experts in Korea!
$10 for up to 10 devsFree for 5 users Totally free
The ultimate workflow
Ultimate Git Workflow - Seoul 2015
Ultimate Git Workflow - Seoul 2015
Ultimate Git Workflow - Seoul 2015
Upcoming SlideShare
Loading in …5
×

Ultimate Git Workflow - Seoul 2015

1,581 views

Published on

Welcome to the Ultimate Git Workflow. Today I will be showing you the techniques that we have developed at Atlassian to work with Git.

Published in: Technology

Ultimate Git Workflow - Seoul 2015

  1. 1. The business case for GitThe ultimate workflow Tim Pettersen • Developer Provocateur • Atlassian • @kannonboy
  2. 2. Tim Pettersen Developer Provocateur @kannonboy
  3. 3. Who knows ?
  4. 4. Facts 800+ Developers
  5. 5. 1800+ Nerds Facts
  6. 6. working on 9+ products Facts
  7. 7. Tools happy developers & productive teams Ship software faster & smarter
  8. 8. Ship software faster & smarter happy developers & productive teams
  9. 9. WHY GIT? THE ULTIMATE WORKFLOW PULL REQUESTS INTERMISSION The ultimate workflow MERGE STRATEGIES CONTINUOUS INTEGRATION COLLABORATION MODELS WHY STASH?
  10. 10. Why
  11. 11. VCS marketshare 2015 Source: Black Duck https://www.openhub.net/repositories/compare 9% 47% 38% 2%
  12. 12. VCS trends (since 2010) -16% -13% +27% +0.75% Source: Red Monk http://redmonk.com/sogrady/2013/12/19/dvcs-and-git-2013/
  13. 13. 0 10 20 30 40 Daily Weekly Monthly Quarterly Yearly git centralized Source: Atlassian Git Survey 2013 release speed: git vs centralized
  14. 14. Speed, speed, Speed
  15. 15. Everything is local
  16. 16. C by Linux kernel and filesystem
  17. 17. But what if my repo is big? 446k lines of code added 1 3 The Linux kernel 3.13 release had 15+ million LOC 1,339 contributors4 2 12,000 non-merge commits source lwn.net
  18. 18. atlassian.com/git Migrating soon?
  19. 19. The Ultimate Workflow Branching
  20. 20. upcoming Release? Can we still fix a bug for the Feature Is the code for that complete? for the current version? HotfixHow do we do a ReviewedHas everyone the code for this feature ?
  21. 21. Git workflow? What’s the best I don’t know!
  22. 22. + different teams + different products different cultures = different workflows Git workflow? What’s the best
  23. 23. Design Workflows your own
  24. 24. Issues Code
  25. 25. JIRA-456 JIRA-123 JIRA-123 JIRA-456 Issues Code
  26. 26. Broken Builds Everybody is affected Photo: Resolute
  27. 27. Code freezes suck Photo: LA (Phot) Kelly Whybrow / MOD Code Freeze
  28. 28. JIRA-456 JIRA-123 Linear workflow
  29. 29. Can’t be released right now Half-baked Features
  30. 30. Code freezes suck Photo: LA (Phot) Kelly Whybrow / MOD Code Freeze Photo: Jason Auch Code Freeze Idle developer Another
  31. 31. JIRA-456 JIRA-123 Linear workflow
  32. 32. feature/JIRA-123 stable master branch isolated feature work master Branching workflow
  33. 33. feature/JIRA-30-user- avatars branch type issue key description Branch per issue
  34. 34. bugfix/JIRA-31-oauth-npe branch type issue key description Branch per issue
  35. 35. hotfix/JIRA-32-wtf-ie8-srsly branch type issue key description Branch per issue
  36. 36. per Branch all the things Branch featurebugdoc change
  37. 37. Why branch? • Isolation • Stability • Traceability
  38. 38. Traceability What’s shipping? git branch --merged git branch --no-merged What’s left to do?
  39. 39. Atlassian Bitbucket Workflow SaaS Workflow
  40. 40. feature/JIRA-123 master Integration Failures feature/JIRA-456 stable master branchUn
  41. 41. developmaster feature/JIRA-123 Integration Failures feature/JIRA-456
  42. 42. develop master feature/JIRA-123 Integration Failures feature/JIRA-456 Continuously deployed to “Staging” Continuously deployed to “Production”
  43. 43. develop master Hotfixes
  44. 44. develop master Hotfixes
  45. 45. develop Hotfixes hotfix/JIRA-1911 master
  46. 46. Atlassian Stash Workflow Mobile, desktop & on-premise server software
  47. 47. Multiple Product Versions feature/JIRA-30 master v 1.2 v 1.1
  48. 48. master v 1.2 v 1.1 bugfix/JIRA-41 Multiple Product Versions
  49. 49. master v 1.2 v 1.1 bugfix/JIRA-41 Multiple Product Versions
  50. 50. master v 1.2 v 1.1 bugfix/JIRA-41 Multiple Product Versions
  51. 51. master v 1.2 v 1.1 bugfix/JIRA-45 Multiple Product Versions
  52. 52. master v 1.2 v 1.1 bugfix/JIRA-45 Multiple Product Versions
  53. 53. master v 1.2 v 1.1 bugfix/JIRA-45 Multiple Product Versions
  54. 54. master v 1.2 v 1.1 bugfix/JIRA-45 Multiple Product Versions
  55. 55. master v 1.2 v 1.1 bugfix/JIRA-45 boring work Multiple Product Versions
  56. 56. Automatic merges with Stash
  57. 57. Merge Strategies
  58. 58. What is a merge? Merge commit develop feature merges keep the context of the feature’s commits
  59. 59. git rebase: Rewrite history safely
  60. 60. feature develop What is a rebase? It’s a way to replay commits, one by one, on top of a branch
  61. 61. develop feature What is a rebase? preserving the order of commits
  62. 62. 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
  63. 63. CUSTOMARY WARNING! rebase rewrites history! Treat this power with great care. Only rewrite history of local branches or…
  64. 64. Rewriting history master alice/master bob/master Original AND rewritten commit are now in history!
  65. 65. DON’T REWRITE PUBLISHED HISTORY (don’t push --force to a shared branch)
  66. 66. feature/JIRA-123 master Merge Commit
  67. 67. feature/JIRA-123 master Rebase (Fast-forward)
  68. 68. feature/JIRA-123 master Rebase (Squash)
  69. 69. Merge Commit Rebase (FF) Rebase (Squash) No merge commits Verbose history Easy to read Can be more difficult to trace changes Which should I use? “Ugly” history Full traceability Hard to screw up mostly some
  70. 70. Intermission!
  71. 71. Trivia!
  72. 72. Which hashing algorithm does git use for generating commit IDs? SHA-1 MD5
  73. 73. The git checkout command can be used to check out an existing branch. True False
  74. 74. The git checkout command can be used to create a new branch. True False
  75. 75. The git checkout command can be used to check out a file. True False
  76. 76. The git checkout command can be used to create a new tag. FalseTrue
  77. 77. What is the purpose of the .gitignore file? ignore files with certain names ignore different line endings
  78. 78. The git DAG (which stores refs, trees and blobs) stands for.. Directed Acyclic Graph Data Agnostic Graph
  79. 79. In git, what is a merge with more than two parents called? OctopusHydra
  80. 80. Creating a new branch from a 40 megabyte working copy will take how much disk space? 40 bytes 40 megabytes
  81. 81. What is a shallow clone? a clone with limited history a clone with no submodules
  82. 82. What is a bare clone? a clone with no working directory a clone with no branches or tags
  83. 83. The git 1.0.0 release was tagged in which year? 2005 2006
  84. 84. Which flag can you pass to the git merge command to make it try harder to detect moved segments within changed files? --patience--tolerance
  85. 85. The first git commit message by Linus Torvalds reads: “Initial revision of git… …the information manager from hell” …bye-bye Bitkeeper”
  86. 86. What command is executed on a git server when you push changes over SSH? git-receive-pack git-upload-pack
  87. 87. It is possible to have more than one root commit in a git repository. True False
  88. 88. What hexadecimal character does the SHA of the root commit of the git project end with? 0 1
  89. 89. TIE-BREAKER
  90. 90. What does this SHA refer to? 4b825dc642cb6eb9a060e54bf8d69288fbee4904 an empty tree an empty blob
  91. 91. Code Review
  92. 92. Code review: why? • Better code - this one is obvious • Teach your co-workers - and learn from them • Lower your bus factor - remove single points of failure
  93. 93. Code review
  94. 94. Pull requests
  95. 95. Pull requests
  96. 96. Pull requests review before merging
  97. 97. Peer Review
  98. 98. 10 tips for better pull requests bit.ly/10-pr-tips (from Mark Seemann a.k.a @ploeh)
  99. 99. 1. make it small bit.ly/10-pr-tips 2. do one thing 4. avoid reformatting
  100. 100. bit.ly/10-pr-tips 3. watch your line width
  101. 101. 5. make sure the code builds bit.ly/10-pr-tips 6. make sure the tests pass 7. add tests
  102. 102. 8. document your reasoning bit.ly/10-pr-tips 9. write well obvious code code comments commit message PR comments> > >
  103. 103. 10. avoid thrashing bit.ly/10-pr-tips
  104. 104. 11. avoid flamewars Photo: MANOJTV
  105. 105. 12. set a team policy
  106. 106. Continuous Integration
  107. 107. automatically triggered Building branches maste r always build master
  108. 108. Is the branch green?
  109. 109. Confounding build breakages master
  110. 110. Confounding build breakages bugfix/JRA-1 master
  111. 111. Is the branch green?
  112. 112. Collaborate Photo: Photographer's Mate 3rd Class Eric S. Garst better
  113. 113. Working with contractors?
  114. 114. Circle of Trust Photo: Aljaz Zajc
  115. 115. Strangers on the internet Contractors Interns Other product teams Support Core dev team Circle of Trust
  116. 116. Collaborating with SVN Core dev team Everyone else emailing patches repository tarballs hell-ish conflicts
  117. 117. Collaborating with forks Everyone else Core dev team Changes automatically synchronize downstream .. but must be reviewed before moving upstream
  118. 118. feature/* Mentoring with branches Senior developers Junior developers maste r
  119. 119. Strangers on the internet Interns Other product teams Support Core dev team Contractors
  120. 120. Why
  121. 121. Why
  122. 122. Git workflows for teams Extensions & Integrations Scalability Why ?
  123. 123. Git workflow for teams feature/STASH-123 master Forking Branching vs
  124. 124. feature/STASH-123 master Git workflow for teams X reviewers approved? Y builds passed? All tasks complete?
  125. 125. feature/STASH-123 master Git workflow for teams Pull request merge checks Repository hooks Branch permissions
  126. 126. feature/STASH-123 master Git workflow for teams Pull request merge checks Repository hooks Branch permissions Flexible & Extensible
  127. 127. Powerful integrations
  128. 128. Powerful integrations
  129. 129. • Full Java API • Repository Hooks • Merge Checks • User Interface • REST end-points • Filetype renderers • SSH commands Stash Platform Branch Permissions REST APIs JIRA Integration Source? You betcha! Plugin APIs
  130. 130. insert /rest/api/latestRESTful APIs
  131. 131. RESTful APIs insert /rest/api/latest
  132. 132. Scalability Request throttling
  133. 133. Request queuing Scalability
  134. 134. Response Caching Scalability
  135. 135. Clustering Scalability
  136. 136. Git workflows for teams Extensions & Integrations Scalability Why ?
  137. 137. BIG thanks to your local experts in Korea!
  138. 138. $10 for up to 10 devsFree for 5 users Totally free The ultimate workflow

×