a sane git workflow
(for the fairly advanced git user who can’t quite
use github’s awesome continuous deployment
methodology because they still have to deal
with versions and releases and other
business / marketing nonsense)
Slide 3
Slide 3 text
No content
Slide 4
Slide 4 text
PROCESS PROCESS PROCESS P
OCESS PROCESS PROCESS PROC
PROCESS PROCESS PROCESS PR
Slide 5
Slide 5 text
PROCESS PROCESS PROCESS P
OCESS PROCESS PROCESS PROC
PROCESS PROCESS PROCESS PR
Do I need to
merge twice?
How do I
resolve this
conflict?
Where do
I merge?
Slide 6
Slide 6 text
PROCESS PROCESS PROCESS P
OCESS PROCESS PROCESS PROC
PROCESS PROCESS PROCESS PR
WTF is
going on?
Do I need to
merge twice?
How do I
resolve this
conflict?
Where do
I merge?
Slide 7
Slide 7 text
develop
What We Really Want
Slide 8
Slide 8 text
develop
ew/add-new-shiny
What We Really Want
Slide 9
Slide 9 text
develop
ew/add-new-shiny
Slide 10
Slide 10 text
develop
ew/add-new-shiny
PULL
REQUEST!
Slide 11
Slide 11 text
No content
Slide 12
Slide 12 text
IT’S JUST NOT
THIS HARD!
Slide 13
Slide 13 text
WHAT WE NEED
simple
prevent merge errors & regressions
consistency
keep everyone working on the latest
code as often as possible
Slide 14
Slide 14 text
LET’S TALK ABOUT
a fresh start
feature branches
release branches
rebasing
bad habits
staging
releasing
Slide 15
Slide 15 text
START
PULL REQUEST
BRANCH
Slide 16
Slide 16 text
START SANE, STAY SANE
master == develop
If it doesn’t, figure out why not!
Unmerged features?
Probably need to break these out.
If all else fails, rename develop to
something else and start clean
USE:feature
branches
branch from develop when
you start a new feature
rebase onto develop often
stay up to date with the
latest and greatest
pull request into develop when done
Slide 21
Slide 21 text
develop
Simple Example:
One shiny new feature
Slide 22
Slide 22 text
develop
ew/new-shiny
git checkout -b ew/new-shiny
Slide 23
Slide 23 text
develop
ew/new-shiny
git commit ...
Slide 24
Slide 24 text
develop
ew/new-shiny
Slide 25
Slide 25 text
develop
ew/new-shiny
Slide 26
Slide 26 text
NO!release
branches
Slide 27
Slide 27 text
NO!release
branches
develop is your release branch
nothing merges into develop until it is
ready to release
you can’t release until everything in
develop is ready
new features branch from, and merge
back into, develop
Slide 28
Slide 28 text
develop
ew/new-shiny
Still Easy:
Two independent new features
kb/moar
Slide 29
Slide 29 text
develop
kb/moar
ew/new-shiny
Slide 30
Slide 30 text
develop
kb/moar
ew/new-shiny
Slide 31
Slide 31 text
develop
kb/moar
ew/new-shiny
Slide 32
Slide 32 text
develop
kb/moar
ew/new-shiny
Slide 33
Slide 33 text
interlude on pull requests:
after the pull request, the branch is done
no more commits!
Slide 34
Slide 34 text
develop
kb/moar
ew/new-shiny
Slide 35
Slide 35 text
develop
kb/moar
ew/new-shiny
Slide 36
Slide 36 text
develop
kb/moar
ew/new-shiny
Slide 37
Slide 37 text
develop
kb/moar
ew/new-shiny
doesn’t have the
changes from
ew/new-shiny!
Slide 38
Slide 38 text
interlude on pull requests:
after the pull request, the branch is done
no more commits!
avoid confusion
delete the branch
interlude on pull requests:
after the pull request, the branch is done
no more commits!
avoid confusion
delete the branch, or
fast-forward to the merged branch
Slide 41
Slide 41 text
REBASE
don’t
fear the
Slide 42
Slide 42 text
REBASE
stay on top of the latest changes
incorporate others’ work into
your own branch
don’t
fear the
Slide 43
Slide 43 text
develop
kb/moar
ew/new-shiny
Small Problem:
@kb needs @ew’s feature to finish
Slide 44
Slide 44 text
develop
kb/moar
ew/new-shiny
REBASE!
git rebase origin/develop
on branch kb/moar:
Slide 45
Slide 45 text
develop
kb/moar
ew/new-shiny
REBASE!
git rebase origin/develop
on branch kb/moar:
Slide 46
Slide 46 text
develop
kb/moar
ew/new-shiny
Slide 47
Slide 47 text
develop
kb/moar
ew/new-shiny
Slide 48
Slide 48 text
REBASE
fear
not the
stay on top of the latest changes
incorporate others’ work into
your own branch
two developers working on the
same feature branch
may depend on each other’s progress
abstract one more level
Slide 49
Slide 49 text
develop
Bigger Problem:
Big new feature needs two developers
Slide 50
Slide 50 text
develop
big-feature
git checkout -b big-feature
on branch develop:
develop
big-feature
jl/big-feature ew/big-feature
REBASE!
git rebase origin/big-feature
on branch ew/big-feature:
Slide 57
Slide 57 text
develop
big-feature
jl/big-feature
ew/big-feature
REBASE!
git rebase origin/big-feature
on branch ew/big-feature:
Slide 58
Slide 58 text
develop
big-feature
jl/big-feature
ew/big-feature
Slide 59
Slide 59 text
develop
big-feature
jl/big-feature
ew/big-feature
Slide 60
Slide 60 text
develop
big-feature
jl/big-feature
ew/big-feature
Slide 61
Slide 61 text
develop
big-feature
jl/big-feature
ew/big-feature
Slide 62
Slide 62 text
develop
big-feature
jl/big-feature
ew/big-feature
\o/ Feature is done!
Slide 63
Slide 63 text
things to note:
no shared branches
rebase at will
fewer pull/merge conflicts
merge code when it won’t break others’
your branch back to feature branch
feature branch back to develop
all merging done by github
code reviews!
if github can’t merge, rebase!
less likely to resolve conflicts incorrectly
Slide 64
Slide 64 text
things to note:
• no shared branches
• rebase at will
• fewer pull/merge conflicts
• merge code when it won’t break others’
• your branch back to feature branch
• feature branch back to develop
• all merging done by github
• code reviews!
• if github can’t merge, rebase!
less likely to resolve conflicts incorrectly!!
Slide 65
Slide 65 text
STOP!with the
bad habits
Slide 66
Slide 66 text
STOP!with the
bad habits
the straight line myth is dead
you’ll have lots of branches
merges are not evil
use GUIs sparingly
this is code, not a pretty picture
git pull is evil
git fetch, followed by git merge
Slide 67
Slide 67 text
No content
Slide 68
Slide 68 text
NO!staging
branch
Slide 69
Slide 69 text
NO!staging
branch
staging is a tag
any developer can tag staging and
deploy their code there
final qa before release? merge features
into develop and tag staging there
Slide 70
Slide 70 text
develop
kb/moar
ew/new-shiny
git tag -f staging
git push -f origin staging
on branch kb/moar:
staging
Slide 71
Slide 71 text
develop
kb/moar
ew/new-shiny
REBASE!
git rebase origin/develop
on branch kb/moar:
Slide 72
Slide 72 text
develop
kb/moar
ew/new-shiny
git tag -f staging
git push -f origin staging
on branch kb/moar:
staging
Slide 73
Slide 73 text
develop
kb/moar
ew/new-shiny
git tag -f staging
on branch develop:
staging
Slide 74
Slide 74 text
PUSH IT!
release
management
Slide 75
Slide 75 text
PUSH IT!
release
management
hotfixes on master
pull request from develop to master
fast-forward develop to master
(branches end after merge)
tag your release
v2.1.5
ew/hotfix
master, develop
jl/new
git rebase origin/develop
on branch kb/hotness:
kb/hotness
v2.2.0
v2.1.1
v2.1.0
Slide 85
Slide 85 text
REVIEW
master == develop
feature branches from develop
don’t share branches!
pull request back to develop
rebase to stay current
hotfix branches from master
pull request back to master
branches end after merge