Real world Git workflows TODO Show of hands Picture with - - PowerPoint PPT Presentation
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
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
15% 38%
from 2011 to 2013
Source: RedMonk Git Survey 2013
You heard is on the rise
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
We’ll cover:
1
Collaboration model We’ll cover:
1 2
Collaboration model We’ll cover: Branching model
1
Practices
2 3
Collaboration model We’ll cover: Branching model
Which collaboration model?
1
Slide Title
Fully decentralized Anarchy
ANARCHY
Fully decentralized Anarchy
I do my thing I do my thing, too
ANARCHY
here’ s mine, who tells john? look ma, a goat!
Blessed repository with Gatekeeper
Gatekeeper
Blessed repository with Gatekeeper
He is cool
Gatekeeper
To have your work accepted, talk to him
and Lieutenants
Dictator
and Lieutenants
Dictator
long live the King! Lieutenants guard the King Blessed repository
Shared common repository
Centralised
Shared common repository
we share “everything”
Centralised
+
+
Enterprise
+
=
Centralized
Enterprise
Builds Metrics Issues Deployments
Builds Metrics Issues Deployments
They know where the code needs to go!
Which branching model?
Which branching model?
2
upcoming Release ? Can we still fix a bug for the
upcoming Release ? Can we still fix a bug for the
Feature
Is the code for that complete?
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
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 ?
Git workflow? What’s the best
Git workflow? What’s the best
We don’ t know!
different cultures
Git workflow? What’s the best
+ different products different cultures
Git workflow? What’s the best
+ different teams + different products different cultures
Git workflow? What’s the best
+ different teams + different products different cultures = different workflows
Git workflow? What’s the best
Design Workflows
your own
- 1. Single branch workflow - aka trunk
Committing locally
Master
Local Repository
Committing locally
Master
Local Repository
Central repository has updates
Central Repository Local Repository
Master Master
Getting updates via rebase
Central Repository Local Repository
Master Master
Getting updates via rebase
Central Repository Local Repository
Master Master
- 2. Feature branching workflow
Creating a branch
master
master Feature #1
Creating a branch
Adding changes
master Feature #1
Merge
master Feature #1
m
Working on features in parallel
master Feature #1 Feature #2
m
Working on features in parallel
master Feature #1 Feature #2
m
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
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
A better way using rebase
master Feature #1 Feature #2
m
Working on features in parallel
master Feature #1 Feature #2
m m m
Working on features in parallel
master Feature #1 Feature #2
m m m
Working on features in parallel
master Feature #1 Feature #2
m m m
- Always with local branches
Working on features in parallel
master Feature #1 Feature #2
m m m
- Always with local branches
- With shared branches: After review, before merging
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
- 3. Continuous delivery workflow
master is in production
1
master is in production
1
promoted from staging, can receive hot-fixes
master is in production
1
staging is the next version
2
promoted from staging, can receive hot-fixes
master is in production
1
staging is the next version new features off staging
2 3
promoted from staging, can receive hot-fixes
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
staging master
- 3. Continuous delivery workflow
feature-1
m
staging master feature-2
- 3. Continuous delivery workflow
m
feature-1
m m
staging master feature-2
- 3. Continuous delivery workflow
m
feature-1
m m m
staging master feature-2
- 3. Continuous delivery workflow
m
feature-1
m m R H m
staging master feature-2
- 3. Continuous delivery workflow
m
feature-1
m m R H
release to production = merge master
In Production
m
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
- 4. Product releases workflow
- ne branch per feature
1
- ne branch per feature
1
- ne branch per bugfix
2
- ne branch per feature
1
- ne branch per bugfix
long running stable branches
2 3
- ne branch per feature
1
- ne branch per bugfix
long running stable branches
2 3
master is alpha/RC status
4
it’s just a normal branching workflow…
master feature-1 feature-2
with long running release branches
master 2.2 2.1 bugfix feature-1 feature-2
Master 2.2
Bugfix Merge
2.1 Bugfix
Master 2.2
Merge into 2.1
2.1 Bugfix
Master 2.2
Merge into 2.2
2.1 Bugfix
Master 2.2
Merge into Master
2.1 Bugfix
Master 2.2 2.1 Bugfix
Automatically merging release branches
Master 2.2 2.1 Bugfix
Automatically merging release branches
Automatic MERGES!
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!
git merge --strategy= resolve
git merge --strategy= recursive
git merge --strategy=
git merge --strategy= ours
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
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
- verall picture
master 2.2 2.1 bugfix feature-1 feature-2
Deep breath, it’s really simple
The merge protocol
The secret sauce
The merge protocol
The secret sauce
When a branch is: Change flows from branch to baseline: Change flows from baseline to branch:
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
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
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
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
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
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
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
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
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
The merge protocol
The secret sauce
Release Branch Master
http:/ /bit.ly/branch-based-workflows
The merge protocol
The secret sauce
Release Branch Master
Merge continually http:/ /bit.ly/branch-based-workflows
The merge protocol
The secret sauce
Release Branch Master
Merge continually Never merge! http:/ /bit.ly/branch-based-workflows
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
http:/ /bit.ly/branch-based-workflows
The merge protocol
The secret sauce
atlassian.com/git
More on git workflows
Practices
Practices
4
What happens to CI with git?
experiment on your feature branch
Running builds on feature branches
experiment on your feature branch
Running builds on feature branches
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
x developer
x developer
times
x push to remote
x developer
times
x push to remote =
lots of builds (waiting)
Running builds on feature branches
automatically manually
feature/IRKD-30 master v 1.2
Code Reviews
Code Reviews
Better Quality Learn Find errors
Pull Requests
part of your daily workflow
Part of your daily work
Part of your daily work
Pull Request
Discuss
Part of your daily work
Pull Request
Discuss
In Conclusion: the recipe
- Branching
Model Adopt Git Practices
- Collaboration
Model
- Branching
Model Adopt Git Practices
- Collaboration
Model Centralized
- Branching
Model Adopt Git Practices
- Product
workflow
- Collaboration
Model Centralized
- Branching
Model Adopt Git Practices
- Product
workflow Continuous delivery workflow
- Collaboration
Model Centralized
- Branching
Model Adopt Git Practices
- Product
workflow Continuous delivery workflow
- Collaboration
Model Centralized Merge protocol
- Branching
Model Adopt Git Practices
- Product
workflow Continuous delivery workflow Build automatically, but leave knobs!
- Collaboration
Model Centralized Merge protocol
- Branching
Model Adopt Git Practices
- Product
workflow Continuous delivery workflow Embrace PR Build automatically, but leave knobs!
- Collaboration
Model Centralized Merge protocol
- Thank you for your
- attention!
- @stefansaasen
- ssaasen@atlassian.com
- www.atlassian.com
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/