Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Git Historian

The Git Historian

Your git repository’s log wants to tell you a story, with valuable clues about how your software became the thing of beauty (or horrible mess) that it is today. You just need to know how and where to look. In this talk, we’ll dig into a project’s history to learn how it evolved, using only the git command line utility to search through commits–no extra software required! To close, we’ll discuss how to leave good clues for future historians.

Aaron Sumner

May 13, 2017
Tweet

More Decks by Aaron Sumner

Other Decks in Programming

Transcript

  1. Disclaimers • Mileage may vary • You probably know something

    I don’t! • Links to slides and references at the end
  2. for development with backup from Webrick" $n=Module.new{extend Rack;a,D,S,q=Rack::Builder.new,Object.method(: define_method),/@@ *([^\n]+)\n(((?!@@)

    [^\n]*\n)*)/m %w[get post put delete].map{|m|D.(m){|u,&b| a.map(u){run->(e){[200,{"Content-Type"=>"text/ html"},[a.instance_eval(&b)]]}}}} Tilt.mappings.map{|k,v|D.(k){|n,*o|$t|| =(h=$u._jisx0301("hash, please");File.read(caller[0][/^[^:] +/]).scan(S){|a,b|h[a]=b};h);v[0].new(*o) {n=="#{n}"?n:$t[n.to_s]}.render(a,o[0].try(: [],:locals)||{})}} %w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try : []}};END{Rack::Handler.get("webrick").run(a,Po rt:$z){|s|$r=s}} !
  3. #

  4. % %

  5. %

  6. Useful flags for git log git log --reverse git log

    --oneline git log --patch (-p) git log -p path/to/file git log -p -S term git log --grep term git log --stat man git-log
  7. Searching git log /pattern ?pattern n for next instance N

    for previous instance j/k one line down/up gg beginning of output G end of output /^commit man less
  8. Tips for a clean commit • Include the code, corresponding

    documentation, and corresponding test coverage • Separate out refactoring that could obfuscate the feature change • Keep other corrections in separate commits
  9. “The seven rules of a great commit message” 1. Separate

    subject from body with a blank line 2. Limit the subject line to 50 characters 3. Capitalize the subject line 4. Do not end the subject line with a period 5. Use the imperative mood in the subject line 6. Wrap the body at 72 characters 7. Use the body to explain what and why vs. how
  10. git rebase --interactive --autosquash git commit --fixup sha git commit

    --squash sha -m “Additional information.”
  11. References • https://everydayrails.com/2017/01/02/git-command-line-log-search.html • http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html • https://chris.beams.io/posts/git-commit/ • http://johnkary.net/blog/git-add-p-the-most-powerful-git-feature-youre-not- using-yet/

    • https://technosorcery.net/blog/2010/02/fun-with-the-upcoming-1-7-release-of- git-rebase-interactive-autosquash/ • https://github.com/rkh/almost-sinatra • https://github.com/thoughtbot/clearance • http://emojipedia.org/