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

Deliberate Git

Deliberate Git

Many teams see Git as a source of frustration. A painful reminder that the rubber needs to meet the road in order to make ends meet and keep our customers happy. They see Git as just a mechanism to transport the code from development machines to production servers and keep everyone in sync.

But I want Git to do more. Being distributed means Git gives us the opportunity to do something really amazing. It allows us to make quick commits locally without breaking flow and then allows us to rewrite those commits into a cohesive story that we share with our team.

This talk describes what makes commits awesome and how you can write them and still keep a good coding flow.

Aaa2b1f12b65d33422e8cdc48d70c0f9?s=128

Stephen Ball

August 17, 2013
Tweet

Transcript

  1. Deliberate Git Stephen Ball

  2. Git

  3. Git Commits

  4. Git Commits == Super Email

  5. Git Commits == Super Email Last forever

  6. Git Commits == Super Email Last forever Are extremely searchable

  7. Git Commits == Super Email Last forever Are extremely searchable

    Are available to everyone
  8. “1.21 gigawatts”

  9. “1.21 gigawatts!?!!”

  10. None
  11. None
  12. Noooo -___-

  13. None
  14. “Forgot to update form action for new lead engine”

  15. “Forgot to update form action for new lead engine” “Switched

    to new lead engine”
  16. None
  17. Replace lead tracking Foo with Bar Foo’s API has dropped

    5 out of the last 27 emails since we started keeping our own logs. Their support is not responding. Fred and I decided to drop in Lead Engine B after checking alternatives (see wiki:LeadEngineResearch).
  18. Replace lead tracking Foo with Bar Foo’s API has dropped

    5 out of the last 27 emails since we started keeping our own logs. Their support is not responding. Fred and I decided to drop in Lead Engine B after checking alternatives (see wiki:LeadEngineResearch).
  19. Replace lead tracking Foo with Bar Foo’s API has dropped

    5 out of the last 27 leads since we started keeping our own logs. Their support is not responding. Fred and I decided to drop in Lead Engine B after checking alternatives (see wiki:LeadEngineResearch).
  20. Replace lead tracking Foo with Bar Foo’s API has dropped

    5 out of the last 27 emails since we started keeping our own logs. Their support is not responding. Fred and I decided to drop in Lead Engine B after checking alternatives (see wiki:LeadEngineResearch).
  21. Good Commit Subjects

  22. Good Commit Subjects Written in the present tense

  23. Good Commit Subjects Written in the present tense Written as

    commands
  24. Good Commit Bodies

  25. Good Commit Bodies Can be informal

  26. Good Commit Bodies Can be informal Describe the “why?”

  27. Good Commit Bodies Can be informal Describe the “why?” Messages

    to your team
  28. Commits Should Tell Us

  29. Commits Should Tell Us What the change does

  30. Commits Should Tell Us What the change does Why it's

    necessary
  31. Commits Might Tell Us

  32. Commits Might Tell Us Alternatives considered

  33. Commits Might Tell Us Alternatives considered Potential consequences

  34. Are Git Commits like Comments?

  35. Are Git Commits like Comments? # set x to 5

    y = 3
  36. Git Commits are always in sync Commits are tied to

    the change They’re comments that expire (automatically)
  37. Can we keep coding flow?

  38. Can we keep coding flow? WIP commits while coding

  39. Can we keep coding flow? WIP commits while coding Commit

    frequently
  40. Can we keep coding flow? WIP commits while coding Commit

    frequently Rewrite your commits
  41. Code, Commit, Rewrite Code Commit Rewrite

  42. Git Rebase

  43. git rebase -i

  44. git rebase -i Rewrite commits Remove commits Combine commits Reorder

    commits
  45. $ git rev-list master..feature | wc -l 37

  46. $ git rev-list master..feature | wc -l 37 $ git

    rebase -i 1123e81 [magic happens] (ů◕‿◕)ů*:ŋƅ✧
  47. $ git rev-list master..feature | wc -l 37 $ git

    rebase -i 1123e81 [magic happens] (ů◕‿◕)ů*:ŋƅ✧ $ git rev-list master..feature | wc -l 5
  48. Using “git rebase -i” Use “git log” to find the

    commit before the first commit you want to change. “git rebase -i [that commit’s hash] Magic time!
  49. $ git l * 193bn13 WIP switch fizz to bazz

    * 6a0b73a WIP support fizz * aa02d1e WIP Start to hack out foo * 3a049ba Allow creating users via JSON $ git rebase -i 3a049ba
  50. pick aa02d1e WIP Start to hack out foo pick 6a0b73a

    WIP support fizz pick 193bn13 WIP switch fizz to bazz # Rebase 31049ba..193bn13 onto 31049ba # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom.
  51. pick aa02d1e WIP Start to hack out foo pick 6a0b73a

    WIP support fizz pick 193bn13 WIP switch fizz to bazz # Rebase 31049ba..193bn13 onto 31049ba # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom.
  52. reword aa02d1e WIP Start to hack out foo fixup 6a0b73a

    WIP support fizz fixup 193bn13 WIP switch fizz to bazz # Rebase 31049ba..193bn13 onto 31049ba # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom.
  53. Add foo feature with bazz support The ability to foo

    has been requested by various users. This implementation will allow foo with support for the bazz protocol. At first we thought that the fizz protocol would be a good fit, but that wasn’t the case when we tested it against over 10,000 interactions. We opened up an issue with the fizz API. - The bazz protocol: http://example.com/bazz - fizz api failure issue: http://example.com/issue/12
  54. Digging into History

  55. Git History Commands git log git log -p git log

    --grep=”commit contents” git log -S”diff contents” git log -- path/or/file git blame FILENAME
  56. Let’s wrap this up

  57. Thank you! Stephen Ball @stephenballnc http://rakeroutes.com