SlideShare a Scribd company logo
Simplify writing code with
deliberate commits
LRUG - June 2019
Joel Chippindale - @joelchippindale
Joel Chippindale
CTO at
Unmade
Video © Rapha Racing Limited 2019. All rights reserved
“If you can’t explain
it simply, you
don’t understand
it well enough.”
- Albert Einstein (probably)
en.wikiquote.org/wiki/Albert_Einstein
Image by Cory Doctorow (CC BY-SA)
Our work requires
us to make changes
to complex systems
@joelchippindale
We learn to break down
complex problems into
small, simple steps
Image by WOCinTech Chat (CC BY)
Great developers are
really good at
breaking problems
into simple steps
@joelchippindale
This takes discipline and
willpower...
@joelchippindale
...but we can learn to
make it easier
@joelchippindale
When I started using git it
changed the way that I
developed software
5 Practices
1. Plan your commits
2. Use single purpose branches
3. Make atomic commits
4. Write good commit messages
5. Rewrite your history to tell a story (early
and often)
Image by Alexander Baxevanis (CC BY)
Practice 1:
Plan your commits
@joelchippindale
Make a plan for the
commits that you will
make
@joelchippindale
What if you don't know
enough yet to make a
plan?
@joelchippindale
What if the plan changes?
@joelchippindale
Plan your commits ahead
of time and re-plan when
you need to
Image by Jon Bennet
Practice 2:
Use single purpose
branches
@joelchippindale
Name your branch to
reflect it's (single)
purpose
@joelchippindale
Notice when you are
starting to work on
something else
@joelchippindale
Notice if a commit has
value independent of the
branch
@joelchippindale
...and if it does, then
'cherry pick' it onto
master
git cherry-pick
# Enables you to apply a single
# commit from another branch
# onto master
master
your-dev-branch
$
A
B
C
D
master
your-dev-branch
git checkout master
A
B
C
D
$
master
your-dev-branch
A
B
C
D
git checkout master$
master
your-dev-branch
A
B
C
DD
git cherry-pick your-dev-branch$
master
your-dev-branch
A
B
C
D
D`
git cherry-pick your-dev-branch$
master
your-dev-branch
A
B
C
D
D`
git checkout your-dev-branch$
master
your-dev-branch
A
B
C
D
D`
git checkout your-dev-branch$
master
your-dev-branch
A
B
C
D
D`
git rebase master$
master
your-dev-branch
A
B
D`
C`
git rebase master$
@joelchippindale
Keep focussed by making
each development
branch single purpose
Image by lupusphotos (CC BY)
Practice 3:
Make atomic
commits
@joelchippindale
Decide the one change
you are going to make
and commit it
@joelchippindale
How big a change should
I make?
@joelchippindale
Minimum valuable
commit
@joelchippindale
Be suspicious of 'and' in
your commit message
@joelchippindale
Notice when you start
doing something else and
stop
git add --patch
# Enables you to review all your
# changes and decide which to
# add to your commit
$ git add --patch
diff --git a/layout/models.py b/layout/models.py
index f2dd5a8..b4dd522 100644
--- a/layout/models.py
+++ b/layout/models.py
@@ -27,7 +27,7 @@ class Layout(models.Model):
def __str__(self):
if self.is_layplan:
- return "Layplan: {}".format(self.data.get("slug", self.code))
+ return "Layplan: {}".format(self.data.get("name", self.code))
else:
return "Layout: {}".format(self.code)
Stage this hunk [y,n,q,a,d,e,?]?
@joelchippindale
Make each step simple by
making atomic commits
Image by Ginny (CC BY-SA)
Practice 4:
Write good commit
messages
dc8f609 It worked for me
a813998 Final commit, ready for tagging
834a288 Don't push this commit
7cd9b24 WTF
901b51c done. going to bed now.
57d298f WIP
704de26 This will definitely work
b4512c6 This might work
d90b710 Trying to fix it again
c57b012 Debug stuff
Note: These messages are mostly taken from http://whatthecommit.com
@joelchippindale
What does good look
like?
Short one line title
Longer description of what the change achieves
(if the title isn’t enough).
An explanation of why the change is being made.
Perhaps a discussion of context and/or
alternatives that were considered.
Short one line title
Longer description of what the change
achieves (if the title isn’t enough).
An explanation of why the change is being
made.
Perhaps a discussion of context and/or
alternatives that were considered.
Short one line title
Longer description of what the change
achieves (if the title isn’t enough).
An explanation of why the change is being
made.
Perhaps a discussion of context and/or
alternatives that were considered.
Short one line title
Longer description of what the change
achieves (if the title isn’t enough).
An explanation of why the change is being
made.
Perhaps a discussion of context and/or
alternatives that were considered.
Short one line title
Longer description of what the change
achieves (if the title isn’t enough).
An explanation of why the change is being
made.
Perhaps a discussion of context and/or
alternatives that were considered.
Correct the colour of FAQ link in course notice footer
PT: https://www.pivotaltracker.com/story/show/84753832
In some email clients the colour of the FAQ link in the
course notice footer was being displayed as blue instead of
white. The examples given in PT are all different versions of
Outlook. Outlook won't implement CSS changes that include `!
important` inline[1]. Therefore, since we were using it to
define the colour of that link, Outlook wasn't applying that
style and thus simply set its default style (blue, like in
most browsers). Removing that `!important` should fix the
problem.
[1] https://www.campaignmonitor.com/blog/post/3143/
outlook-2007-and-the-inline-important-declaration/
@joelchippindale
Clear space in your head
by writing good commit
messages
Image by Nic McPhee (CC BY-SA)
Practice 5:
Rewrite your history
to tell a simple story
(early and often)
@joelchippindale
You make mistakes and
change your mind
git rebase --interactive
# Enables you to move, reorder,
# edit, merge and split your
# commits
343eed2 Fix typo in foo
ba66794 Add bar
90328f9 Add foo
git rebase --interactive master
1 pick 90328f9 Add foo
2 pick ba66794 Add bar
3 pick 343eed2 Fix typo in foo
4
5 # Rebase c405e59..343eed2 onto c405e59 (3 commands)
6 #
7 # Commands:
8 # p, pick <commit> = use commit
9 # r, reword <commit> = use commit, but edit the commit message
10 # e, edit <commit> = use commit, but stop for amending
11 # s, squash <commit> = use commit, but meld into previous commit
12 # f, fixup <commit> = like "squash", but discard this commit's log message
13 # x, exec <command> = run command (the rest of the line) using shell
14 # b, break = stop here (continue rebase later with 'git rebase --continue')
15 # d, drop <commit> = remove commit
16 # l, label <label> = label current HEAD with a name
17 # t, reset <label> = reset HEAD to a label
1 pick 90328f9 Add foo
2 pick 343eed2 Fix typo in foo
3 pick ba66794 Add bar
4
5 # Rebase c405e59..343eed2 onto c405e59 (3 commands)
6 #
7 # Commands:
8 # p, pick <commit> = use commit
9 # r, reword <commit> = use commit, but edit the commit message
10 # e, edit <commit> = use commit, but stop for amending
11 # s, squash <commit> = use commit, but meld into previous commit
12 # f, fixup <commit> = like "squash", but discard this commit's log message
13 # x, exec <command> = run command (the rest of the line) using shell
14 # b, break = stop here (continue rebase later with 'git rebase --continue')
15 # d, drop <commit> = remove commit
16 # l, label <label> = label current HEAD with a name
17 # t, reset <label> = reset HEAD to a label
1 pick 90328f9 Add foo
2 fixup 343eed2 Fix typo in foo
3 pick ba66794 Add bar
4
5 # Rebase c405e59..343eed2 onto c405e59 (3 commands)
6 #
7 # Commands:
8 # p, pick <commit> = use commit
9 # r, reword <commit> = use commit, but edit the commit message
10 # e, edit <commit> = use commit, but stop for amending
11 # s, squash <commit> = use commit, but meld into previous commit
12 # f, fixup <commit> = like "squash", but discard this commit's log message
13 # x, exec <command> = run command (the rest of the line) using shell
14 # b, break = stop here (continue rebase later with 'git rebase --continue')
15 # d, drop <commit> = remove commit
16 # l, label <label> = label current HEAD with a name
17 # t, reset <label> = reset HEAD to a label
4a14d7b Add bar
c296093 Add foo
@joelchippindale
Make your progress clear
by rewriting your history
to tell a simple story
To recap the 5 practices
1. Plan your commits
2. Use single purpose branches
3. Make atomic commits
4. Write good commit messages
5. Rewrite your history to tell a story (early
and often)
git cherry-pick
git add --patch
git rebase --interactive
@joelchippindale
Following these 5
practices will free up your
brain and help you break
work into small steps
@joelchippindale
As an added bonus...
@joelchippindale
...it can also provide
valuable documentation
for your code
“Every line of code is
always documented”
- Mislav Marohnić
mislav.net/2014/02/hidden-documentation/
@joelchippindale
Thank you
Joel Chippindale - CTO at Unmade - @joelchippindale
Thanks to my teams at Unmade, FutureLearn and Econsultancy who have all
helped develop and refine these habits.
Come and work with us at Unmade
www.unmade.com/careers/
@joelchippindale
Links for more info
•A Branch in Time (a story about revision histories)
•Every line of code is always documented
•Telling stories with your Git history

More Related Content

Similar to Simplify writing code with deliberate commits (20)

PDF
Telling stories through your commits (Jan 2015)
FutureLearn
 
PDF
Catalyst - refactor large apps with it and have fun!
mold
 
PDF
GIT Basics
Tagged Social
 
PDF
Telling stories through your commits - Lead Developer Conference 2016
Joel Chippindale
 
PPTX
Core .NET Framework 4.0 Enhancements
Robert MacLean
 
PDF
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Codemotion
 
PDF
Cpp17 and Beyond
ComicSansMS
 
PDF
Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"
NodeUkraine
 
PPTX
C++ Core Guidelines
Thomas Pollak
 
PPTX
FluentMigrator - Dayton .NET - July 2023
Matthew Groves
 
PDF
CMake best practices
Henry Schreiner
 
PPTX
GIT in a nutshell
alignan
 
PDF
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Atlassian
 
PDF
A short guide to git's interactive rebase
Ombu Labs, The Lean Software Boutique
 
PPTX
Automatically Documenting Program Changes
Ray Buse
 
PDF
Tool Time
Ken Collins
 
PDF
Functional Smalltalk
ESUG
 
PDF
Ad505 dev blast
Bill Buchan
 
PDF
Git in pills : git stash
Federico Panini
 
Telling stories through your commits (Jan 2015)
FutureLearn
 
Catalyst - refactor large apps with it and have fun!
mold
 
GIT Basics
Tagged Social
 
Telling stories through your commits - Lead Developer Conference 2016
Joel Chippindale
 
Core .NET Framework 4.0 Enhancements
Robert MacLean
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Codemotion
 
Cpp17 and Beyond
ComicSansMS
 
Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"
NodeUkraine
 
C++ Core Guidelines
Thomas Pollak
 
FluentMigrator - Dayton .NET - July 2023
Matthew Groves
 
CMake best practices
Henry Schreiner
 
GIT in a nutshell
alignan
 
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Atlassian
 
A short guide to git's interactive rebase
Ombu Labs, The Lean Software Boutique
 
Automatically Documenting Program Changes
Ray Buse
 
Tool Time
Ken Collins
 
Functional Smalltalk
ESUG
 
Ad505 dev blast
Bill Buchan
 
Git in pills : git stash
Federico Panini
 

Recently uploaded (20)

PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
July Patch Tuesday
Ivanti
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
July Patch Tuesday
Ivanti
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Ad

Simplify writing code with deliberate commits