Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Logs Are Magic! Why git workflows & commit structure should matter to you

175 views

Published on

As given at The Perl Conference, 21 Jun 2017

Published in: Software
  • Be the first to comment

  • Be the first to like this

Logs Are Magic! Why git workflows & commit structure should matter to you

  1. 1. logs are magic! john sj anderson | @genehack | the perl conference | swamptown usa 1 — Logs Are MAGIC! — TPC 2017 — @genehack
  2. 2. why git workflows & commit structure should matter to you john sj anderson | @genehack | the perl conference | swamptown usa 2 — Logs Are MAGIC! — TPC 2017 — @genehack
  3. 3. hi, i'm john. a/k/a @genehack 3 — Logs Are MAGIC! — TPC 2017 — @genehack
  4. 4. vp, tech infinity interactive 4 — Logs Are MAGIC! — TPC 2017 — @genehack
  5. 5. i ❤ revision control5 — Logs Are MAGIC! — TPC 2017 — @genehack
  6. 6. cvs6 — Logs Are MAGIC! — TPC 2017 — @genehack
  7. 7. svn7 — Logs Are MAGIC! — TPC 2017 — @genehack
  8. 8. rcs8 — Logs Are MAGIC! — TPC 2017 — @genehack
  9. 9. rcs9 — Logs Are MAGIC! — TPC 2017 — @genehack
  10. 10. git10 — Logs Are MAGIC! — TPC 2017 — @genehack
  11. 11. i ❤ git 11 — Logs Are MAGIC! — TPC 2017 — @genehack
  12. 12. quick poll! 12 — Logs Are MAGIC! — TPC 2017 — @genehack
  13. 13. what this talk isn't13 — Logs Are MAGIC! — TPC 2017 — @genehack
  14. 14. nouniversal truths14 — Logs Are MAGIC! — TPC 2017 — @genehack
  15. 15. not even "best practices"15 — Logs Are MAGIC! — TPC 2017 — @genehack
  16. 16. what this talk is16 — Logs Are MAGIC! — TPC 2017 — @genehack
  17. 17. some opinions 17 — Logs Are MAGIC! — TPC 2017 — @genehack
  18. 18. backed up with experience 18 — Logs Are MAGIC! — TPC 2017 — @genehack
  19. 19. maybe more important for larger projects 19 — Logs Are MAGIC! — TPC 2017 — @genehack
  20. 20. but also good for projects that aspire to be bigger20 — Logs Are MAGIC! — TPC 2017 — @genehack
  21. 21. maybe more relevant for coding projects 21 — Logs Are MAGIC! — TPC 2017 — @genehack
  22. 22. but also applicable for doc or config repos 22 — Logs Are MAGIC! — TPC 2017 — @genehack
  23. 23. making better use of history 23 — Logs Are MAGIC! — TPC 2017 — @genehack
  24. 24. making better history24 — Logs Are MAGIC! — TPC 2017 — @genehack
  25. 25. prerequisites 25 — Logs Are MAGIC! — TPC 2017 — @genehack
  26. 26. consistency 26 — Logs Are MAGIC! — TPC 2017 — @genehack
  27. 27. habits 27 — Logs Are MAGIC! — TPC 2017 — @genehack
  28. 28. do it all the time28 — Logs Are MAGIC! — TPC 2017 — @genehack
  29. 29. then you don't have to think about it29 — Logs Are MAGIC! — TPC 2017 — @genehack
  30. 30. even better30 — Logs Are MAGIC! — TPC 2017 — @genehack
  31. 31. automate it31 — Logs Are MAGIC! — TPC 2017 — @genehack
  32. 32. how to make better history 32 — Logs Are MAGIC! — TPC 2017 — @genehack
  33. 33. workflows 33 — Logs Are MAGIC! — TPC 2017 — @genehack
  34. 34. no remote no branches master only 34 — Logs Are MAGIC! — TPC 2017 — @genehack
  35. 35. local master no branches & periodic pushes 35 — Logs Are MAGIC! — TPC 2017 — @genehack
  36. 36. git flow 36 — Logs Are MAGIC! — TPC 2017 — @genehack
  37. 37. some notable antipatterns37 — Logs Are MAGIC! — TPC 2017 — @genehack
  38. 38. squashed branches 38 — Logs Are MAGIC! — TPC 2017 — @genehack
  39. 39. fast forward merges39 — Logs Are MAGIC! — TPC 2017 — @genehack
  40. 40. rebase before merge40 — Logs Are MAGIC! — TPC 2017 — @genehack
  41. 41. all destroy history41 — Logs Are MAGIC! — TPC 2017 — @genehack
  42. 42. all destroy history needlessly 42 — Logs Are MAGIC! — TPC 2017 — @genehack
  43. 43. a linear commit history is a lie43 — Logs Are MAGIC! — TPC 2017 — @genehack
  44. 44. a linear commit history is a lie (probably) 44 — Logs Are MAGIC! — TPC 2017 — @genehack
  45. 45. instead 45 — Logs Are MAGIC! — TPC 2017 — @genehack
  46. 46. some good patterns46 — Logs Are MAGIC! — TPC 2017 — @genehack
  47. 47. branch 47 — Logs Are MAGIC! — TPC 2017 — @genehack
  48. 48. branch for errythang48 — Logs Are MAGIC! — TPC 2017 — @genehack
  49. 49. (specifics will vary)49 — Logs Are MAGIC! — TPC 2017 — @genehack
  50. 50. have a release branch50 — Logs Are MAGIC! — TPC 2017 — @genehack
  51. 51. release may be master release may be another branch 51 — Logs Are MAGIC! — TPC 2017 — @genehack
  52. 52. (again, specifics will vary) 52 — Logs Are MAGIC! — TPC 2017 — @genehack
  53. 53. merging to the release branch is a release53 — Logs Are MAGIC! — TPC 2017 — @genehack
  54. 54. (ideally, automatically) 54 — Logs Are MAGIC! — TPC 2017 — @genehack
  55. 55. make all merges non-FF55 — Logs Are MAGIC! — TPC 2017 — @genehack
  56. 56. an aside 56 — Logs Are MAGIC! — TPC 2017 — @genehack
  57. 57. ~/.gitconfig 57 — Logs Are MAGIC! — TPC 2017 — @genehack
  58. 58. git config --global merge.ff false git config --global pull.ff only 58 — Logs Are MAGIC! — TPC 2017 — @genehack
  59. 59. [merge] ff = false [pull] ff = only 59 — Logs Are MAGIC! — TPC 2017 — @genehack
  60. 60. maximal historical information60 — Logs Are MAGIC! — TPC 2017 — @genehack
  61. 61. keep it clean61 — Logs Are MAGIC! — TPC 2017 — @genehack
  62. 62. ~/.gitconfig aliases 62 — Logs Are MAGIC! — TPC 2017 — @genehack
  63. 63. [alias] br = branch ci = commit -v co = checkout st = status 63 — Logs Are MAGIC! — TPC 2017 — @genehack
  64. 64. clean up remote branches 64 — Logs Are MAGIC! — TPC 2017 — @genehack
  65. 65. git push origin --delete <branch> 65 — Logs Are MAGIC! — TPC 2017 — @genehack
  66. 66. nuke = push origin --delete 66 — Logs Are MAGIC! — TPC 2017 — @genehack
  67. 67. clean up orphaned remote-tracking branches67 — Logs Are MAGIC! — TPC 2017 — @genehack
  68. 68. git remote prune origin 68 — Logs Are MAGIC! — TPC 2017 — @genehack
  69. 69. prune = remote prune origin 69 — Logs Are MAGIC! — TPC 2017 — @genehack
  70. 70. find unmerged branches70 — Logs Are MAGIC! — TPC 2017 — @genehack
  71. 71. git branch --no-merged master 71 — Logs Are MAGIC! — TPC 2017 — @genehack
  72. 72. git branch --no-merged --remote master 72 — Logs Are MAGIC! — TPC 2017 — @genehack
  73. 73. unmerged = branch --no-merged unmerged-remote = branch --no-merged --remote 73 — Logs Are MAGIC! — TPC 2017 — @genehack
  74. 74. keep it clean74 — Logs Are MAGIC! — TPC 2017 — @genehack
  75. 75. one final note on branches75 — Logs Are MAGIC! — TPC 2017 — @genehack
  76. 76. branch names76 — Logs Are MAGIC! — TPC 2017 — @genehack
  77. 77. a branch equals a ticket77 — Logs Are MAGIC! — TPC 2017 — @genehack
  78. 78. the ticket id should be in the branch name 78 — Logs Are MAGIC! — TPC 2017 — @genehack
  79. 79. along with something for the humans79 — Logs Are MAGIC! — TPC 2017 — @genehack
  80. 80. put the number at the end of the branch name 80 — Logs Are MAGIC! — TPC 2017 — @genehack
  81. 81. good: fix-login-864 81 — Logs Are MAGIC! — TPC 2017 — @genehack
  82. 82. meh: fix-864 82 — Logs Are MAGIC! — TPC 2017 — @genehack
  83. 83. bad: 864-crap 83 — Logs Are MAGIC! — TPC 2017 — @genehack
  84. 84. !!!: foobar 84 — Logs Are MAGIC! — TPC 2017 — @genehack
  85. 85. just. don't. 85 — Logs Are MAGIC! — TPC 2017 — @genehack
  86. 86. when merging include the branch name86 — Logs Are MAGIC! — TPC 2017 — @genehack
  87. 87. default message works nicely 87 — Logs Are MAGIC! — TPC 2017 — @genehack
  88. 88. Merge branch <name> 88 — Logs Are MAGIC! — TPC 2017 — @genehack
  89. 89. maximal historical information89 — Logs Are MAGIC! — TPC 2017 — @genehack
  90. 90. to review 90 — Logs Are MAGIC! — TPC 2017 — @genehack
  91. 91. don't squash 91 — Logs Are MAGIC! — TPC 2017 — @genehack
  92. 92. don't fast forward 92 — Logs Are MAGIC! — TPC 2017 — @genehack
  93. 93. don't rebase before merge 93 — Logs Are MAGIC! — TPC 2017 — @genehack
  94. 94. don't destroy your history 94 — Logs Are MAGIC! — TPC 2017 — @genehack
  95. 95. use branches 95 — Logs Are MAGIC! — TPC 2017 — @genehack
  96. 96. use a release branch 96 — Logs Are MAGIC! — TPC 2017 — @genehack
  97. 97. use no-ff to make merge commits 97 — Logs Are MAGIC! — TPC 2017 — @genehack
  98. 98. keep your repo clean 98 — Logs Are MAGIC! — TPC 2017 — @genehack
  99. 99. let's get more granular 99 — Logs Are MAGIC! — TPC 2017 — @genehack
  100. 100. structuring individual commits100 — Logs Are MAGIC! — TPC 2017 — @genehack
  101. 101. a commit equals one "change"101 — Logs Are MAGIC! — TPC 2017 — @genehack
  102. 102. important: at each commit the software must work102 — Logs Are MAGIC! — TPC 2017 — @genehack
  103. 103. git bisect 103 — Logs Are MAGIC! — TPC 2017 — @genehack
  104. 104. smaller >> bigger 104 — Logs Are MAGIC! — TPC 2017 — @genehack
  105. 105. whitespace & formatting 105 — Logs Are MAGIC! — TPC 2017 — @genehack
  106. 106. always go in distinct commits106 — Logs Are MAGIC! — TPC 2017 — @genehack
  107. 107. remember! 107 — Logs Are MAGIC! — TPC 2017 — @genehack
  108. 108. revision is also a thing108 — Logs Are MAGIC! — TPC 2017 — @genehack
  109. 109. what you eventually push109 — Logs Are MAGIC! — TPC 2017 — @genehack
  110. 110. !=110 — Logs Are MAGIC! — TPC 2017 — @genehack
  111. 111. your commits while working 111 — Logs Are MAGIC! — TPC 2017 — @genehack
  112. 112. savepoints 112 — Logs Are MAGIC! — TPC 2017 — @genehack
  113. 113. every working micro step 113 — Logs Are MAGIC! — TPC 2017 — @genehack
  114. 114. single "change" 10-15 commits 114 — Logs Are MAGIC! — TPC 2017 — @genehack
  115. 115. git add --patch 115 — Logs Are MAGIC! — TPC 2017 — @genehack
  116. 116. git add -p 116 — Logs Are MAGIC! — TPC 2017 — @genehack
  117. 117. git commit --amend 117 — Logs Are MAGIC! — TPC 2017 — @genehack
  118. 118. editor support118 — Logs Are MAGIC! — TPC 2017 — @genehack
  119. 119. magit fugitive github.atom.io119 — Logs Are MAGIC! — TPC 2017 — @genehack
  120. 120. magit 120 — Logs Are MAGIC! — TPC 2017 — @genehack
  121. 121. don't push first drafts 121 — Logs Are MAGIC! — TPC 2017 — @genehack
  122. 122. tell a story 122 — Logs Are MAGIC! — TPC 2017 — @genehack
  123. 123. interactive rebasegit rebase -i 123 — Logs Are MAGIC! — TPC 2017 — @genehack
  124. 124. sometimes may be useful to preserve dead ends 124 — Logs Are MAGIC! — TPC 2017 — @genehack
  125. 125. ...as a warning for others 125 — Logs Are MAGIC! — TPC 2017 — @genehack
  126. 126. commit messages126 — Logs Are MAGIC! — TPC 2017 — @genehack
  127. 127. ticket numbers in the subject 127 — Logs Are MAGIC! — TPC 2017 — @genehack
  128. 128. (at the end) 128 — Logs Are MAGIC! — TPC 2017 — @genehack
  129. 129. you can customize the template for the commit message 129 — Logs Are MAGIC! — TPC 2017 — @genehack
  130. 130. git config --local commit.template ./.template # edit .template to add whatever you want... 130 — Logs Are MAGIC! — TPC 2017 — @genehack
  131. 131. commit message examples131 — Logs Are MAGIC! — TPC 2017 — @genehack
  132. 132. good: make login form use POST instead of GET [#864] 132 — Logs Are MAGIC! — TPC 2017 — @genehack
  133. 133. meh: fixed form [#864] 133 — Logs Are MAGIC! — TPC 2017 — @genehack
  134. 134. bad: 846 fix 134 — Logs Are MAGIC! — TPC 2017 — @genehack
  135. 135. !!!: foo 135 — Logs Are MAGIC! — TPC 2017 — @genehack
  136. 136. ( °□° 136 — Logs Are MAGIC! — TPC 2017 — @genehack
  137. 137. this is why daddy drinks 137 — Logs Are MAGIC! — TPC 2017 — @genehack
  138. 138. to review 138 — Logs Are MAGIC! — TPC 2017 — @genehack
  139. 139. 1 commit == 1 change 139 — Logs Are MAGIC! — TPC 2017 — @genehack
  140. 140. commit messages matter! 140 — Logs Are MAGIC! — TPC 2017 — @genehack
  141. 141. when in doubt make it smaller 141 — Logs Are MAGIC! — TPC 2017 — @genehack
  142. 142. (make the commit smaller NOTthe commit message) 142 — Logs Are MAGIC! — TPC 2017 — @genehack
  143. 143. segregate formatting changes143 — Logs Are MAGIC! — TPC 2017 — @genehack
  144. 144. use checkpoint commits as savepoints 144 — Logs Are MAGIC! — TPC 2017 — @genehack
  145. 145. don't push first drafts 145 — Logs Are MAGIC! — TPC 2017 — @genehack
  146. 146. revise to tell a story146 — Logs Are MAGIC! — TPC 2017 — @genehack
  147. 147. or at least make yourself look smart147 — Logs Are MAGIC! — TPC 2017 — @genehack
  148. 148. using history better148 — Logs Are MAGIC! — TPC 2017 — @genehack
  149. 149. jfri149 — Logs Are MAGIC! — TPC 2017 — @genehack
  150. 150. just friggin' read it150 — Logs Are MAGIC! — TPC 2017 — @genehack
  151. 151. ~/.gitconfig (again) 151 — Logs Are MAGIC! — TPC 2017 — @genehack
  152. 152. color support152 — Logs Are MAGIC! — TPC 2017 — @genehack
  153. 153. [color] branch = auto diff = auto grep = auto interactive = auto showbranch = auto status = auto ui = auto 153 — Logs Are MAGIC! — TPC 2017 — @genehack
  154. 154. [color "status"] added = green bold changed = red bold untracked = cyan bold 154 — Logs Are MAGIC! — TPC 2017 — @genehack
  155. 155. git diff 155 — Logs Are MAGIC! — TPC 2017 — @genehack
  156. 156. git diff -w 156 — Logs Are MAGIC! — TPC 2017 — @genehack
  157. 157. git diff --word-diff 157 — Logs Are MAGIC! — TPC 2017 — @genehack
  158. 158. git diff --word-diff=color 158 — Logs Are MAGIC! — TPC 2017 — @genehack
  159. 159. blame 159 — Logs Are MAGIC! — TPC 2017 — @genehack
  160. 160. git blame 160 — Logs Are MAGIC! — TPC 2017 — @genehack
  161. 161. git blame -w -M 161 — Logs Are MAGIC! — TPC 2017 — @genehack
  162. 162. [alias] praise = blame 162 — Logs Are MAGIC! — TPC 2017 — @genehack
  163. 163. editorintegration163 — Logs Are MAGIC! — TPC 2017 — @genehack
  164. 164. M-x git-blame-for-line 164 — Logs Are MAGIC! — TPC 2017 — @genehack
  165. 165. git blame -L <line>,<line> <file> git log -L <line>,<line>:<file> 165 — Logs Are MAGIC! — TPC 2017 — @genehack
  166. 166. git blame -L 1,1 index.html 166 — Logs Are MAGIC! — TPC 2017 — @genehack
  167. 167. git blame -L 10,50 index.html 167 — Logs Are MAGIC! — TPC 2017 — @genehack
  168. 168. git blame -L 20,+10 index.html 168 — Logs Are MAGIC! — TPC 2017 — @genehack
  169. 169. git log -L 1,1:index.html 169 — Logs Are MAGIC! — TPC 2017 — @genehack
  170. 170. git log -L 10,50:index.html 170 — Logs Are MAGIC! — TPC 2017 — @genehack
  171. 171. git log -L 20,+10:index.html 171 — Logs Are MAGIC! — TPC 2017 — @genehack
  172. 172. git log -S <string> 172 — Logs Are MAGIC! — TPC 2017 — @genehack
  173. 173. git log --follow 173 — Logs Are MAGIC! — TPC 2017 — @genehack
  174. 174. git lg 174 — Logs Are MAGIC! — TPC 2017 — @genehack
  175. 175. log --graph --abbrev-commit --date=relative --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' 175 — Logs Are MAGIC! — TPC 2017 — @genehack
  176. 176. 176 — Logs Are MAGIC! — TPC 2017 — @genehack
  177. 177. --graph 177 — Logs Are MAGIC! — TPC 2017 — @genehack
  178. 178. --abbrev-commit 178 — Logs Are MAGIC! — TPC 2017 — @genehack
  179. 179. --date=relative 179 — Logs Are MAGIC! — TPC 2017 — @genehack
  180. 180. --pretty=format: '%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' 180 — Logs Are MAGIC! — TPC 2017 — @genehack
  181. 181. 181 — Logs Are MAGIC! — TPC 2017 — @genehack
  182. 182. takeaways! 182 — Logs Are MAGIC! — TPC 2017 — @genehack
  183. 183. history is important183 — Logs Are MAGIC! — TPC 2017 — @genehack
  184. 184. it's probably worth more of your time184 — Logs Are MAGIC! — TPC 2017 — @genehack
  185. 185. both creating it and using it 185 — Logs Are MAGIC! — TPC 2017 — @genehack
  186. 186. don't just stop when the software works186 — Logs Are MAGIC! — TPC 2017 — @genehack
  187. 187. software development is hard187 — Logs Are MAGIC! — TPC 2017 — @genehack
  188. 188. be kind to others188 — Logs Are MAGIC! — TPC 2017 — @genehack
  189. 189. be kind to your future self189 — Logs Are MAGIC! — TPC 2017 — @genehack
  190. 190. thank you! 190 — Logs Are MAGIC! — TPC 2017 — @genehack
  191. 191. 191 — Logs Are MAGIC! — TPC 2017 — @genehack
  192. 192. questions? 192 — Logs Are MAGIC! — TPC 2017 — @genehack
  193. 193. 193 — Logs Are MAGIC! — TPC 2017 — @genehack

×