Effective Git: better commits via inspecting history and code archeology

Effective Git: better commits via inspecting history and code archeology

By Andrew Grangaard (‎spazm‎) from losangeles.pm
Date: Monday, 8 June 2015 17:30
Duration: 20 minutes
Target audience: Intermediate
Language: English
Tags: git review tools

You can find more information on the speaker's site:

* pdf: https://dl.dropboxusercontent.com/u/15585350/presentations/yapc-git-20150608.pdf
* keynote: https://www.dropbox.com/sh/oj00q61vre73w9k/AAAVurEr5_aP3_lbbruxDJMSa?dl=0
* youtube: https://www.youtube.com/watch?v=oS-mMKnAAL0


Harness the power of Version Control to view a project's evolution over time. I'll show you how to delve your codebase, extracting context from commit messages and diffs. Learning that commits are not write-only will motivate you to write better commits and better code. Your collaborators will thank you!



We all know that reading code is critical to improving as developers:

* Reading code makes you a better writer of code.
* Reading commit messages makes you a committer of code, a better developer.
* Reading commit diffs shows you how to better stage and layout your commits.

Harness the power of Version Control to view a project’s evolution over time. We have the luxury of moving forward and backwards through the history of our projects, viewing changes through time and reading sign posts along the journey. Experience reading commit messages will prove how useful they are at sharing the mental model behind the code. Reading historical commit messages and viewing diffs improves our ability to document and stage our own commits. Commits are not write-only! They are messages from the past that tell us about our present.

I’ll show you the tools I use for diving into a new code base and how I interact with my current projects on a daily basis. I’ll show how I answer the questions that come up when reading and debugging code. I’ll show you how I stage and rebase my commits to make a readable history. You’re keystrokes away from pivoting from code to annotation to arbitrary diffs then cross-corelate commit messages with your ticketing system.

Questions we’ll ask your code:
* Why is this code here?
* Who wrote it?
* What did the full change look like?
* What did they/I think it would do?
* How did they think the world worked?
* How long has it been broken?
* Was this comment ever correct?
* What else was changed with this?

* git commands: log, annotate/blame, show, diff, difftool, web, ammend, rebase -a, tag, branch, grep, bisect
* git add-ons: tig; gitx; github web interface, tickets and pull-requests; ack
* Editor integration: vim fugitive for diff and annotate, ctags for cross-file tracing

* Learn to better communicate with your current and future team and self!
* Practice reading commit messages to form opinions on good vs poor messages and produce more of the former.
* http://stopwritingramblingcommitmessages.com/
* Improved proficiency and comfort with git workflow
* Getting started with a new project — Digging into the historical commits and messages to see the evolution from initial idea to functioning project.
* Post-hoc code review. How did we get where we are?

“The ratio of time spent reading (code) versus writing is well over 10 to 1 … (therefore) making it easy to read makes it easier to write.” — Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship

“If I had eight hours to chop down a tree, I’d spend six sharpening my axe.” — AbrahamLincoln

Attended by: Andrew Grangaard (‎spazm‎), Brad Lhotsky, Marcus Del Greco, Curtis Jewell (‎CSJewell‎), Garth Hill, Tony Chambers, Daniel Fackrell, Jared Miller, Erik Peterson, Karl Williamson, Mark Gardner (‎mjgardner‎), Tom Christiansen, Kevin Metcalf (‎profmetcalf‎), James E Keenan (‎kid51‎), Michael LaGrasta, James Morgan (‎Ven'Tatsu‎), Faelin Landy (‎wolf‎), Buddy Burden (‎barefootcoder‎), Brad Oaks (‎bradoaks‎), Jan Peterson (‎jlp‎), Yanick Champoux (‎Yanick‎), Rick Bychowski (‎rickbike‎), Drew Taylor (‎drewbie‎), Ben Grimm, Jason Fuller, Greg Cole (‎wingfold‎), Thomas Stanton (‎tstanton‎), Mickey Nasriachi (‎Mickey‎), Andy Bach, Adam Rich, Joseph Alsop, morgan jones, Neelima Gaddam, Jeff Smith, Dillan Hildebrand, Cora Davis, Weldon Whipple, Jason Terry, Philip Rhinelander, Paul Millard, Abigail, Josh Lavin (‎digory‎), Allie Rogers, Andrea Nall, Irina Todeva, Aran Deltac (‎bluefeet‎), Nathan Sullivan, Chad Granum (‎Exodist‎), Michael Hamlin (‎myrrhlin‎), Mark Swayne, Andrew Baerg, Steve Nolte (‎mcsnolte‎), Mark Wells, Maximilian Witte, Norman Yamada, Matthew Green, Shawn Moore (‎sartak‎), Miller Hall, Mike Greb (‎mikegrb‎), Gary Norton, Tim Bunce, shane utt (‎sutt‎), Sean Murphy, Bruce Gray (‎Util‎), Ryan Olson (‎Gimpson‎), Prairie Nyx, R Geoffrey Avery (‎rGeoffrey‎),