SlideShare a Scribd company logo
1 of 39
Download to read offline
On Committing Well
James Aylett
What is a commit?
Changes
What they were based on (parent commits)
Message
Author (& optional committer), timestamp
A name (SHA)
What is a good commit?
Changes that do a single thing
What they were based on (parent commits)
Message that describes the thing clearly
Author (& optional committer), timestamp
A name (SHA)
What is a good commit?
Changes that do a single thing
What they were based on (parent commits)
Message that describes the thing clearly
Author (& optional committer), timestamp
A name (SHA)
Do a single thing
Only make one change per commit
Make the whole change in one commit
Avoid committing code that’s been
commented out
Do a single thing
Only make one change per commit
Make the whole change in one commit
Avoid committing code that’s been
commented out
One change per commit
Commits are objects in git, so we can
work with them using git revert, git
cherry-pick and git rebase
But this only works if a commit does one
thing
Yes, you can use interactive rebase to split
commits after the fact, but it’s painful
One change per commit
!
If you need to reformat or fix whitespace, that
is its own commit
Refactors are their own commits
Other bugs fixed are their own commits, but
ideally, don’t get sidetracked — note it down
for later
One change per commit
!
If you have multiple changes per commit,
it’s almost impossible to write a good
commit message (which we’ll shortly
discuss further)
git add -p is your friend, as is using
the index incrementally
Do a single thing
Only make one change per commit
Make the whole change in one commit
Avoid committing code that’s been
commented out
The whole change in one
Commits are much easier to review
Even if you review at a PR level, well-
sized commits make it easier to see the
structure of the change
Also important in later forensics eg git
bisect
The whole change in one
Check your commits before you push, or
at least before you make a PR
You can coalesce commits using git
rebase -i
You can force push your rebased changes
just before making a PR
The whole change in one
if you add commits in response to review
comments, you can rebase then force
push to the PR’s branch after code review
before merge
we could use a tag to indicate desire for
a final rebase step and avoid zealous
merges
Do a single thing
Only make one change per commit
Make the whole change in one commit
Avoid committing code that’s been
commented out
Avoid commented code
If it used to be live code, it’s in the history
If not and you “might need it later”:
put it in a commit (possibly on a different branch)
or stash it
or just leave it in your working tree
by the way you probably won’t need it later
What is a good commit?
Changes that do a single thing
What they were based on (parent commits)
Message that describes the thing clearly
Author (& optional committer), timestamp
A name (SHA)
Describe it clearly
Start with a short (50 chars) summary
Describe the effect not the code
Ideally use the imperative: “fix bug” not
“fixed bug” (matches git auto-messages
on merges for instance)
Describe it clearly
Start with a short (50 chars) summary
Describe the effect not the code
Ideally use the imperative: “fix bug” not
“fixed bug” (matches git auto-messages
on merges for instance)
A short summary
most of git (and particularly git
rebase -i, git show-branch) will
truncate if it can’t fit
lots of people’s terminal are 80 characters
wide (and git needs space for the SHA)
github is also designed for this length
A short summary
!
More detail follows in longer (72 chars)
lines
Maybe reference issue tracker — however
git history is likely to live longer, so don’t
omit key details of implementation (from
pragmatic planning)
Describe it clearly
Start with a short (50 chars) summary
Describe the effect not the code
Ideally use the imperative: “fix bug” not
“fixed bug” (matches git auto-messages
on merges for instance)
Describe the effect
No point describing the code changes: the code
changes are already part of the commit
However capturing intent, how these changes solve
the problem or satisfy the feature, is important
Helps code review (is the intent what I expect? does
the code match the intent?)
Helps future forensics: why is this code there or
written in that way?
Describe it clearly
Start with a short (50 chars) summary
Describe the effect not the code
Ideally use the imperative: “fix bug” not
“fixed bug” (matches git auto-messages
on merges for instance)
How about some
examples?
Too terse
!
Relies on the link to the github issue.
!
Better to be more specific here:
!
De-emphasise short utterances in search results
Too terse
!
The intent is captured, but the context isn’t clear unless
you know the project well: this change is in metadata for
a Spacelog mission, and it configures how mission
timestamps are displayed.
!
Better would be:
!
Don’t show days in timestamps
!
The whole mission lasts less than a day.
Playful and informal, but not terrible
!
The commit (there’s more) does actually escape all the
things (not previously escaped).
!
It would be helpful to list the things escaped, in case it
turns out we’d missed one.
Too playful
!
The summary is pretty good (although it could have
mentioned that the commit also implements the confirm
email step itself).
!
The detail is taking playfulness too far: “carefully” refers to
the view which is defensive about using the confirmation
URL if logged in as another user already: spelling this out
would have been much better.
Good level of detail
!
Summary captures the point.
!
Detail explains why, pulls out details of the RE (which are
difficult to read in the changeset).
!
Also notes that this was needed on OS X, so anyone
working on this in future has a concrete platform to test
against to see if they’re correct.
Almost completely useless
!
Firstly, describing the way python works unless it’s a weird
corner case is a waste of time.
!
Secondly, it doesn’t explain what it was about sizes.max that
needed fixing.
!
Thirdly, the change doesn’t just take into account that
range() is exclusive at the top end — because it raises its
parameter by two, not just by one, without explanation.
Just terrible
!
“Play with” is a big warning sign, because commits have
intent, but play does not.
!
Better to be explicit:
!
Improve error reporting around common problems
!
- show line number when can’t parse page or tape number
- when being verbose, print raw lines as we translate them
Reading
A Note About Git Commit Messages by
Tim Pope (http://tbaggery.com/
2008/04/19/a-note-about-git-commit-
messages.html)
What’s in a Good Commit? by Timo
Mihaljov (http://dev.solita.fi/2013/07/04/
whats-in-a-good-commit.html)

More Related Content

Similar to On committing well

Git essential training & sharing self
Git essential training & sharing selfGit essential training & sharing self
Git essential training & sharing selfChen-Tien Tsai
 
Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developersDmitry Guyvoronsky
 
SessionThree_IntroductionToVersionControlSystems
SessionThree_IntroductionToVersionControlSystemsSessionThree_IntroductionToVersionControlSystems
SessionThree_IntroductionToVersionControlSystemsHellen Gakuruh
 
devops-complete-notes-2.pdf
devops-complete-notes-2.pdfdevops-complete-notes-2.pdf
devops-complete-notes-2.pdfRobinRohit2
 
Crafting Better Commits
Crafting Better CommitsCrafting Better Commits
Crafting Better CommitsBrant Burnett
 
Commit to good commit messages
Commit to good commit messagesCommit to good commit messages
Commit to good commit messagesHenrique Moody
 
Practical Git by Greg Hermo
Practical Git by Greg HermoPractical Git by Greg Hermo
Practical Git by Greg HermoGreg Hermo
 
Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git John Tighe
 
Contributing to Upstream Open Source Projects
Contributing to Upstream Open Source ProjectsContributing to Upstream Open Source Projects
Contributing to Upstream Open Source ProjectsScott Garman
 
Git Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdfGit Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdfuzair
 

Similar to On committing well (20)

Git Best Practices.pptx
Git Best Practices.pptxGit Best Practices.pptx
Git Best Practices.pptx
 
Intro to Gitflow
Intro to GitflowIntro to Gitflow
Intro to Gitflow
 
Git & Code review
Git & Code reviewGit & Code review
Git & Code review
 
Git essential training & sharing self
Git essential training & sharing selfGit essential training & sharing self
Git essential training & sharing self
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developers
 
2to3
2to32to3
2to3
 
SessionThree_IntroductionToVersionControlSystems
SessionThree_IntroductionToVersionControlSystemsSessionThree_IntroductionToVersionControlSystems
SessionThree_IntroductionToVersionControlSystems
 
Git_new.pptx
Git_new.pptxGit_new.pptx
Git_new.pptx
 
devops-complete-notes-2.pdf
devops-complete-notes-2.pdfdevops-complete-notes-2.pdf
devops-complete-notes-2.pdf
 
GIT Rebasing and Merging
GIT Rebasing and MergingGIT Rebasing and Merging
GIT Rebasing and Merging
 
Crafting Better Commits
Crafting Better CommitsCrafting Better Commits
Crafting Better Commits
 
Gitting better
Gitting betterGitting better
Gitting better
 
Commit to good commit messages
Commit to good commit messagesCommit to good commit messages
Commit to good commit messages
 
Practical Git by Greg Hermo
Practical Git by Greg HermoPractical Git by Greg Hermo
Practical Git by Greg Hermo
 
Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git
 
Contributing to Upstream Open Source Projects
Contributing to Upstream Open Source ProjectsContributing to Upstream Open Source Projects
Contributing to Upstream Open Source Projects
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git hub party-20151008
Git hub party-20151008Git hub party-20151008
Git hub party-20151008
 
Git Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdfGit Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdf
 

More from James Aylett

Git, from the beginning
Git, from the beginningGit, from the beginning
Git, from the beginningJames Aylett
 
Django Files — A Short Talk (slides only)
Django Files — A Short Talk (slides only)Django Files — A Short Talk (slides only)
Django Files — A Short Talk (slides only)James Aylett
 
IA Isn't New, or: What would Samuel Pepys' website look like?
IA Isn't New, or: What would Samuel Pepys' website look like?IA Isn't New, or: What would Samuel Pepys' website look like?
IA Isn't New, or: What would Samuel Pepys' website look like?James Aylett
 
Django Files — A Short Talk
Django Files — A Short TalkDjango Files — A Short Talk
Django Files — A Short TalkJames Aylett
 
/dev/fort: you can build it in a week @emw
/dev/fort: you can build it in a week @emw/dev/fort: you can build it in a week @emw
/dev/fort: you can build it in a week @emwJames Aylett
 
Accessible by Voice
Accessible by VoiceAccessible by Voice
Accessible by VoiceJames Aylett
 
Spacelog: things we did right-ish
Spacelog: things we did right-ishSpacelog: things we did right-ish
Spacelog: things we did right-ishJames Aylett
 
Five class-based views everyone has written by now
Five class-based views everyone has written by nowFive class-based views everyone has written by now
Five class-based views everyone has written by nowJames Aylett
 

More from James Aylett (10)

Git, from the beginning
Git, from the beginningGit, from the beginning
Git, from the beginning
 
Django Files — A Short Talk (slides only)
Django Files — A Short Talk (slides only)Django Files — A Short Talk (slides only)
Django Files — A Short Talk (slides only)
 
IA Isn't New, or: What would Samuel Pepys' website look like?
IA Isn't New, or: What would Samuel Pepys' website look like?IA Isn't New, or: What would Samuel Pepys' website look like?
IA Isn't New, or: What would Samuel Pepys' website look like?
 
Django Files — A Short Talk
Django Files — A Short TalkDjango Files — A Short Talk
Django Files — A Short Talk
 
Beyond blockers
Beyond blockersBeyond blockers
Beyond blockers
 
/dev/fort: you can build it in a week @emw
/dev/fort: you can build it in a week @emw/dev/fort: you can build it in a week @emw
/dev/fort: you can build it in a week @emw
 
Accessible by Voice
Accessible by VoiceAccessible by Voice
Accessible by Voice
 
Spacelog: things we did right-ish
Spacelog: things we did right-ishSpacelog: things we did right-ish
Spacelog: things we did right-ish
 
Web heresies
Web heresiesWeb heresies
Web heresies
 
Five class-based views everyone has written by now
Five class-based views everyone has written by nowFive class-based views everyone has written by now
Five class-based views everyone has written by now
 

Recently uploaded

Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 

Recently uploaded (20)

Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 

On committing well

  • 2. What is a commit? Changes What they were based on (parent commits) Message Author (& optional committer), timestamp A name (SHA)
  • 3. What is a good commit? Changes that do a single thing What they were based on (parent commits) Message that describes the thing clearly Author (& optional committer), timestamp A name (SHA)
  • 4. What is a good commit? Changes that do a single thing What they were based on (parent commits) Message that describes the thing clearly Author (& optional committer), timestamp A name (SHA)
  • 5. Do a single thing Only make one change per commit Make the whole change in one commit Avoid committing code that’s been commented out
  • 6. Do a single thing Only make one change per commit Make the whole change in one commit Avoid committing code that’s been commented out
  • 7. One change per commit Commits are objects in git, so we can work with them using git revert, git cherry-pick and git rebase But this only works if a commit does one thing Yes, you can use interactive rebase to split commits after the fact, but it’s painful
  • 8. One change per commit ! If you need to reformat or fix whitespace, that is its own commit Refactors are their own commits Other bugs fixed are their own commits, but ideally, don’t get sidetracked — note it down for later
  • 9. One change per commit ! If you have multiple changes per commit, it’s almost impossible to write a good commit message (which we’ll shortly discuss further) git add -p is your friend, as is using the index incrementally
  • 10. Do a single thing Only make one change per commit Make the whole change in one commit Avoid committing code that’s been commented out
  • 11. The whole change in one Commits are much easier to review Even if you review at a PR level, well- sized commits make it easier to see the structure of the change Also important in later forensics eg git bisect
  • 12. The whole change in one Check your commits before you push, or at least before you make a PR You can coalesce commits using git rebase -i You can force push your rebased changes just before making a PR
  • 13. The whole change in one if you add commits in response to review comments, you can rebase then force push to the PR’s branch after code review before merge we could use a tag to indicate desire for a final rebase step and avoid zealous merges
  • 14. Do a single thing Only make one change per commit Make the whole change in one commit Avoid committing code that’s been commented out
  • 15. Avoid commented code If it used to be live code, it’s in the history If not and you “might need it later”: put it in a commit (possibly on a different branch) or stash it or just leave it in your working tree by the way you probably won’t need it later
  • 16. What is a good commit? Changes that do a single thing What they were based on (parent commits) Message that describes the thing clearly Author (& optional committer), timestamp A name (SHA)
  • 17. Describe it clearly Start with a short (50 chars) summary Describe the effect not the code Ideally use the imperative: “fix bug” not “fixed bug” (matches git auto-messages on merges for instance)
  • 18. Describe it clearly Start with a short (50 chars) summary Describe the effect not the code Ideally use the imperative: “fix bug” not “fixed bug” (matches git auto-messages on merges for instance)
  • 19. A short summary most of git (and particularly git rebase -i, git show-branch) will truncate if it can’t fit lots of people’s terminal are 80 characters wide (and git needs space for the SHA) github is also designed for this length
  • 20. A short summary ! More detail follows in longer (72 chars) lines Maybe reference issue tracker — however git history is likely to live longer, so don’t omit key details of implementation (from pragmatic planning)
  • 21. Describe it clearly Start with a short (50 chars) summary Describe the effect not the code Ideally use the imperative: “fix bug” not “fixed bug” (matches git auto-messages on merges for instance)
  • 22. Describe the effect No point describing the code changes: the code changes are already part of the commit However capturing intent, how these changes solve the problem or satisfy the feature, is important Helps code review (is the intent what I expect? does the code match the intent?) Helps future forensics: why is this code there or written in that way?
  • 23. Describe it clearly Start with a short (50 chars) summary Describe the effect not the code Ideally use the imperative: “fix bug” not “fixed bug” (matches git auto-messages on merges for instance)
  • 25.
  • 26. Too terse ! Relies on the link to the github issue. ! Better to be more specific here: ! De-emphasise short utterances in search results
  • 27.
  • 28. Too terse ! The intent is captured, but the context isn’t clear unless you know the project well: this change is in metadata for a Spacelog mission, and it configures how mission timestamps are displayed. ! Better would be: ! Don’t show days in timestamps ! The whole mission lasts less than a day.
  • 29.
  • 30. Playful and informal, but not terrible ! The commit (there’s more) does actually escape all the things (not previously escaped). ! It would be helpful to list the things escaped, in case it turns out we’d missed one.
  • 31.
  • 32. Too playful ! The summary is pretty good (although it could have mentioned that the commit also implements the confirm email step itself). ! The detail is taking playfulness too far: “carefully” refers to the view which is defensive about using the confirmation URL if logged in as another user already: spelling this out would have been much better.
  • 33.
  • 34. Good level of detail ! Summary captures the point. ! Detail explains why, pulls out details of the RE (which are difficult to read in the changeset). ! Also notes that this was needed on OS X, so anyone working on this in future has a concrete platform to test against to see if they’re correct.
  • 35.
  • 36. Almost completely useless ! Firstly, describing the way python works unless it’s a weird corner case is a waste of time. ! Secondly, it doesn’t explain what it was about sizes.max that needed fixing. ! Thirdly, the change doesn’t just take into account that range() is exclusive at the top end — because it raises its parameter by two, not just by one, without explanation.
  • 37.
  • 38. Just terrible ! “Play with” is a big warning sign, because commits have intent, but play does not. ! Better to be explicit: ! Improve error reporting around common problems ! - show line number when can’t parse page or tape number - when being verbose, print raw lines as we translate them
  • 39. Reading A Note About Git Commit Messages by Tim Pope (http://tbaggery.com/ 2008/04/19/a-note-about-git-commit- messages.html) What’s in a Good Commit? by Timo Mihaljov (http://dev.solita.fi/2013/07/04/ whats-in-a-good-commit.html)