List

Commit Messages to the rescue!

Commit Messages to the rescue!

by Christopher "Aji" Slater

The video titled 'Commit Messages to the Rescue!' features Christopher 'Aji' Slater, who presents at RailsConf 2019, discussing the importance of effective commit messages in software development.

The talk emphasizes that commit messages are more than just formalities; they serve as a crucial means of communication about the changes made in a codebase. Aji highlights how well-crafted commit messages can act as 'time capsules' that provide insight and context for past code changes, which is invaluable for maintaining and debugging software. The following key points are discussed:

  • Overview of Commit Messages: Aji stresses the significance of commit messages, suggesting that they often get overlooked, leading to vague and uninformative messages like 'Fixed a bug'. He explains how these messages can save developers from confusion later.

  • Common Practices and Pitfalls: Many developers simplify commit messages to just the '-m' argument in git, neglecting the body of the message. Aji encourages using a structured approach where messages include not just the 'what' but also the 'why' of each commit.

  • Structuring Messages: He provides guidelines for writing effective commit messages, including keeping subjects concise, using the correct tense, and ensuring the body provides context. Aji illustrates his points with examples of both good and poor commit messages, demonstrating how context can greatly enhance the understanding of code changes.

  • Inspirational Examples: Referring to Dr. Seuss, Aji draws an analogy between story context and commit messages, explaining how both can convey deeper meanings when supplemented with proper context. He suggests thinking of commit messages as artifacts for future developers, akin to archaeological discoveries.

  • Utilizing Tools and Automation: He discusses tools like commit templates, linters, and hooks that can automate and enforce good practices within a team. This helps ensure everyone adheres to the same standards, thereby improving code quality and project documentation.

  • Adopting Empathy: The concluding message revolves around empathy—encouraging developers to think about the future maintainers of their code and to strive for clarity and usefulness in their commit messages.

Overall, Aji's talk is an informative session filled with insights on how to elevate the quality of commit messages to enhance team communication and software maintainability, encouraging attendees to be 'commit message archaeologists' that leave useful insights for future developers.

RailsConf 2019 - Commit Messages to the rescue! by Christopher "Aji" Slater
_______________________________________________________________________________________________
Cloud 66 - Pain Free Rails Deployments
Cloud 66 for Rails acts like your in-house DevOps team to build, deploy and maintain your Rails applications on any cloud or server.

Get $100 Cloud 66 Free Credits with the code: RailsConf-19
($100 Cloud 66 Free Credits, for the new user only, valid till 31st December 2019)

Link to the website: https://cloud66.com/rails?utm_source=-&utm_medium=-&utm_campaign=RailsConf19
Link to sign up: https://app.cloud66.com/users/sign_in?utm_source=-&utm_medium=-&utm_campaign=RailsConf19
_______________________________________________________________________________________________
What if I told you there is more to a commit message than "-m"? Like source code time capsules, those pesky formalities can deliver wisdom and perspective about any code from the best possible source, the developer who just wrote it! Explore new facets of these time traveling rubber duck opportunities to increase their usefulness tenfold. Tools like templates, linters, hooks, and automation. Hear what Dr. Seuss can teach us about git, and don't miss the most helpful morsel of git customization around... how to open a new message in an editor other than vim!

RailsConf 2019

00:00:21.170 okay so name of the talk commit messages to the rescue
00:00:26.270 my name is og so it's a pretty short
00:00:31.829 name but a lot of people still have trouble with it spelled right up there aj i and you say it like ah g just like that and just so
00:00:40.230 that you never forget who i am i'd like you all to do it along with me okay i'll spell it out aj i and i want to hear you
00:00:45.780 say Oh G okay aj i ah gee that was good that was good but you
00:00:52.530 didn't do the snap so one more time if you would humor me please aj i ah G excellent I like it the entire
00:01:01.859 room sounds disappointed in me a good thing I'm comfortable now though so my
00:01:07.950 pronouns are he/him website is in the upper left twitter is in the upper right if Twitter is a thing that you do and i
00:01:14.700 100% understand if you just can't and i know that you have a choice in
00:01:19.950 conference talks and i want to thank you for being here with me i work for a company called snap sheet based in
00:01:25.649 chicago we're not unleashing the world's creativity or anything and i don't
00:01:31.080 honestly have a pithy one-liner to explain what we do but a story from a friend of mine and i think is the best way to describe it he called an uber
00:01:39.209 went down us stood outside waiting for the uber stood next to his motorcycle and he were pulled up and smashed right
00:01:45.090 into his bike knocked it over the uber driver said oh no it's okay which is terrifying in and of itself we said no
00:01:51.270 it's not that's my bike and he anticipated weeks of shopping around at body shops and having to fight with his
00:01:57.959 insurance carrier and seeing which one he could get and if it would ever get fixed in months but the next day he got
00:02:05.069 a text from his carrier down to download our app took pictures of his damage with
00:02:10.440 the phone and he had money in his account the next day so technically our customers are the insurance companies
00:02:15.780 we're streamlining processes saving millions of dollars increasing increasing efficiency but it's what we
00:02:22.709 can do for the people like brett that make it exciting for me and here's where I insert the obligatory we're hiring
00:02:28.859 statement come work with me and let's make beautiful commit messages I give a lightning talk version of this
00:02:37.260 before and I wanted to set up some of the situations in which commit messages could really save your bacon so I
00:02:42.870 fabricated a story about a workplace that could have been helped by good message practice when looking at what
00:02:48.989 pictures to put on my slides during this story I reached for dr. Seuss imagery I
00:02:54.959 especially liked it because the fish could be the project manager and that just felt right to me so I started
00:03:01.859 looking at the pictures and thinking well I'm gonna give this talk at railsconf that's a little bit bigger than the other venue why not go all out
00:03:08.400 so I present to you get ad get r em get commit - em definitely not by dr. Seuss
00:03:18.230 an e-commerce site on AWS is a good enough scene for our story I guess they
00:03:25.409 employed devs much more than a few but I'd like to speak of thing 1 and thing 2 now thing one took some work from their
00:03:32.519 burn it down chart seems a bug had been found in the site shopping cart even through all the planning down deep in
00:03:38.790 rails magic requests had timed out causing dips in their traffic thing one race to make known what was causing the
00:03:45.359 fault sweating anxious the server might catch fire and halt for a week without sleep many cans of Lacroix at long last
00:03:51.870 I've uncovered our one tragic flaw with get blame we find out the thing - wrote
00:03:57.419 the class that for the last week was a pain in our workflow now it's readable
00:04:04.410 tested but something's amiss no one class should employ as much logic as this it made sense at the time said
00:04:11.310 thing to unrepentant and you know all of my code is self documenting so you say
00:04:18.810 said thing one but it needs a refactor now help me find out just what that method is after seems like dead code to
00:04:25.979 me not much more than obstruction then their fix was merged in and they pushed to production I had so much fun doing
00:04:32.099 this you guys but there sigh of relief only lasted a flash never before had a sight started
00:04:38.910 crashing so fast looking at server logs their heartbeats all quicken hey I wonder if we could ask
00:04:44.640 that Sean Griffin he maintained active record his opinion I trust now he'll
00:04:50.220 just tell us we should have used rust so call Aaron Patterson called ehh we're
00:04:56.850 hemorrhaging money all over the place as our devs contemplate the lost data and sales think when code loses context apps
00:05:04.890 run off the rails see what I did there okay funs over down to business
00:05:19.040 come have I said just you know we all do them and kind of like TD we all agree that they're very important but we
00:05:25.110 probably cut some corners here and there and I don't want to stand up here and tell you all that you're doing something
00:05:31.110 wrong because you're not you might just not be getting the most out of your
00:05:36.300 commit messages in general version control is something that's not fairly early on in learning to code so the
00:05:43.320 concepts need to be imparted in uncomplicated ways and I bet I know a couple of those it's a save point like
00:05:49.680 in a video game or a moment captured in time or saving your work as you go along
00:05:56.210 whether it was like those are not I'm fairly confident that there wasn't too much time spent on it and we all just
00:06:02.070 used - em at the time either when you're
00:06:07.230 first learning coding or first learning get there's a lot to take in it is a little inaccessible at best so
00:06:13.620 simplifying the steps is important to help learn so we're shown - am told to write a brief description and move on
00:06:19.350 especially because if we type get commits without the - M we were going to get stuck in a Twilight Zone from which
00:06:25.620 there is no escape yes that's right get commit was going to land us in vim
00:06:32.120 and now much like I've seen the one true light and used them as my daily driver now that I have more familiarity I've
00:06:38.910 circled back around to commit messages and get because when these messages aren't thought about as a tool but as a
00:06:45.270 hindrance to work or is it sure that we have to do that doesn't really matter we end up with messages that are unhelpful
00:06:54.460 incredulous maybe a bit on the nose even
00:07:01.700 desperate dishonest depressing downright
00:07:10.970 belligerent yeah I've got nothing I like
00:07:20.900 though that couple kiss didn't get translated into an emoji so I listen to
00:07:25.910 a podcast called the bike shed and in days gone by it was hosted by Sean Griffin and Derek Pryor and somewhere in there who really remembers when Sean
00:07:32.720 started to talk about what a good commit message was and how it can save you from bad situations I thought to myself
00:07:39.080 alright this is a guy who talks about complicated code concepts like it's nothing and so often I have no idea what
00:07:46.490 he is talking about but commit messages there's a bit of wisdom from this programming celebrity that I can put
00:07:52.730 into practice so I started to look into commit messages I read some blogs a
00:07:58.040 forum poster to plenty of Stack Overflow questions and a few pieces of advice rose to the top time and time again show
00:08:06.110 of hands how many people who've heard or seen rules a lot like this and you use
00:08:12.140 them let's hand them down how many people are seeing these ideas for the first time okay some of these have
00:08:22.120 reasons behind them you keep the subject short because git and github will truncate it around fifty characters
00:08:28.930 capital letter period tense you use those are all just tabs and spaces
00:08:34.479 there's a convention that we gravitate to probably those rules but if your team or your project prefers something else
00:08:40.970 has a different style guide we'll go for it and dash em well we'll see why that
00:08:46.580 shortcut is the same as an ice-cream breakfast it's nice at the time but it's not going to help you get through the
00:08:51.950 day
00:08:57.270 let's take a moment look at some well intentioned commit messages that pulled off of github again please with the show
00:09:03.880 of hands how many of you written a commit message like this or this one
00:09:12.180 what about this one so what all of these
00:09:17.350 examples have in common they all follow those canonical rules
00:09:22.930 don't they they might enforce some stylistic consistency but really they're addressing the wrong things because
00:09:28.660 those examples all had something else in common every last one of those did not
00:09:34.300 include a body to the commit message the habit of not using message bodies is so prevalent that I bet there are some
00:09:40.510 developers out there who are capable smart great developers that have never written a commit message body there
00:09:47.050 might be some at this conference or even in this room and to you if you're out
00:09:52.240 there I cannot wait to share this new perspective on this boring common tool because it absolutely can be a
00:09:58.630 game-changer now we've seen some examples and it seems pretty easy to
00:10:04.720 agree on what makes a good what makes a commit message unhelpful so what goes into a good commit message this is from
00:10:12.820 an open source project by thoughtbot called clearance with the subject line I'll read this out because it might be
00:10:18.160 hard to see actually that's pretty big but use route independent password reset redirect body is using edit user
00:10:25.149 password URL requires that particular path helper to exist that's not necessarily the case since all we want
00:10:31.810 to do is redirect to the same action we can use URL for instead it's a concise
00:10:36.910 but descriptive subject in two sentences this message conveys the problem that required a change to be made the
00:10:42.970 intention of the code originally and therefore what the change is aiming for and references the main point of the
00:10:48.399 solution this is the little commit message that could so much conveyed with only as much text as it needs sure this
00:10:56.290 is more to Taif than a 50 character - and message but wouldn't you already have this kind of information if your
00:11:02.260 head in your head if you had just made this change it's not really a lot of extra work to make this kind of thing
00:11:07.990 happen let's take a look at an example from Rails fix secret
00:11:14.290 key base for rail ties this was missed in the security fix for local dev CI doesn't have a temp directory in the
00:11:20.590 apps built for testing so these end up failing this adds the secret key base so we don't need to generate one this talks
00:11:27.340 about the problem being fixed even where and how the bug was introduced and this can certainly be useful mentions what
00:11:33.730 this commit adds and why again this is less than the amount of information that you would share with someone who walked
00:11:40.120 by your desk and asked what you were working on but it gives us a lot to work with if we're thinking about under
00:11:45.310 changing the underlying code so what made those messages better than some of
00:11:51.700 the others that we've looked at context but wise contacts so important will
00:11:58.600 illustrate my point I'm going to go back to a dr. Seuss story not another poem sorry but a story about Theodore Geisel
00:12:06.160 that's his real name and one of his stories horton hears a who that Arielle
00:12:11.350 thankfully left out of his slides so that I could still do it in which an
00:12:17.170 elephant named Horton views vows to protect a tiny civilization that's floating on a speck of dust met with
00:12:23.620 ridicule from the other animals who can't or won't hear them Horton proclaims a person's a person no matter
00:12:29.920 how small well here's some context for you Theodore Geisel was born in 1904 and
00:12:35.980 like many white people at the time was pretty darned racist I'm not going to put those images on screen but famously
00:12:42.040 he do troubling images of Japanese citizens in the run-up to World War two is a political cartoonist amongst far
00:12:48.370 too many other examples but after the war he traveled to Japan and met the
00:12:54.130 people there saw the relationship with the American occupation and heard their direct experience with nuclear weapons
00:13:00.070 he wrote horton hears a who as an allegory about the war some lines in
00:13:05.260 there are straight references to the atom bomb falling from the sky he also
00:13:11.290 drew this cartoon at the top it says what this country needs is a good mental insecticide which is a line of Americans
00:13:18.910 coming up to Uncle Sam to have insecticide sprayed in their ear and forcing out the
00:13:24.130 prejudice bug without the context Horton is a silly book with a good message with
00:13:31.540 context it becomes one man's attempt to admit to the wrongs of his past attitudes in a very public way he tried
00:13:38.649 to influence others to realize the same mistakes in themselves or at the very least inoculate the youngins as best as
00:13:44.529 he could just as a work of art cannot be fully understood without context code
00:13:50.410 can be difficult to impossible to wrap your head around without it the commit itself is going to tell you who what
00:13:57.100 where when how but it's missing why it's a blessing and a curse of programming
00:14:02.529 that there are a million different ways to solve every problem it's less like engineering and math and more like
00:14:08.230 creative writing we're constantly making decisions that have consequences to the
00:14:14.350 future and there's always a reason that we make the decisions that we do even if it's sometimes a little thin record that
00:14:20.829 reason and a commit message because you or someone else might need it I mean how many times have you looked into a file
00:14:26.680 that you didn't write only to think why does this look like this wouldn't it be
00:14:33.100 great if we could hover over a line of code in our editors and read a note explaining exactly why a thing looks
00:14:38.980 like the way it does well you can here it is in BS code this is an extremely
00:14:45.910 popular extension called get lens this file is in the rails source code active record you can see the module name on
00:14:52.180 line three we're gonna jump down a few lines and however hover the mouse on line 44 look at that it's beautiful
00:15:00.990 have you ever had an annotated Shakespeare book before it really opens up the text in a way that you probably
00:15:08.350 had never experienced it how about annotated source code you've already got
00:15:14.199 it who's all this context for anyway other developers developers who are
00:15:21.939 changing this code or using this API or debugging an issue basically anyone who might write something that EXA coats our
00:15:28.240 code in the future but what if I'm the only one working on this great
00:15:36.850 other developers can beam you in the future to properly review code you're
00:15:43.959 going to need more than just seeing the change especially if you're using a tool that truncates add if the reviewer might
00:15:50.109 not even be seeing all the code that's affected by this change if you see there on the left the line numbers go from 120
00:15:58.329 to 167 that's 47 lines of hidden code who knows what could be in there without
00:16:04.449 opening each and every fold in the UI okay but that's what the PR comment is
00:16:11.379 for 100% agree that means also that
00:16:16.539 you're already thinking that context is important so why wouldn't you save it in the history instead of throwing it out
00:16:22.239 with the code when it gets merged or when the code gets merged not with the code that'd be bad
00:16:27.660 has anyone ever searched for something because you're stuck only to find a blog post from one of your colleagues or even
00:16:34.629 yourself that gives you the answer anybody that definitely happened to me you can have that without googling or if
00:16:41.019 your internet is down with rich messaging what's going to be easier to
00:16:47.139 capture context while you're closer to your thoughts or a summary at the end of feature work after the fact it's the
00:16:53.350 same thing with TDD writing tests upfront and as you work or going back in and struggling to cover all your bases
00:17:01.409 okay I'm willing to admit that this is what won me over to actually doing TDD instead of just thinking it was a good
00:17:07.990 idea when you're in the middle of feature development you have all the energy of an exciting new task and if we
00:17:14.019 write our thoughts in the get history as we go we can leverage that immediacy and capture helpful information for the
00:17:19.929 project's future developers and tooling makes it easy to copy out any relevant
00:17:25.120 information for code review and put it right there and a PR you don't have to write it twice the body of a commit
00:17:32.230 message doesn't need to be a novel or an entire page of documentation the explanation should match the size of the
00:17:37.809 context that you have to share so what do we write well if it's part of a
00:17:43.539 public interface how could it be used or extended what's relying on it
00:17:49.750 we're rails developers we love conventions we can all speak more or less the same language and it should be
00:17:55.240 easy for new developers to come on to a project if it all looks rails e-enough did something need to go against a
00:18:02.020 convention for some reason is there a non-obvious side effect that falls out
00:18:08.110 of this change and really what is obvious even mean I know
00:18:13.360 okay this never happens but if it did and the actual execution of a library
00:18:25.330 introduces are there any pitfalls that you saw when you were up to your elbows in this subsystem that would be good to
00:18:31.270 know about in the future think about what precise domain knowledge you have
00:18:36.490 right then that you might want to remember and try to write a message that
00:18:42.429 will make sense without seeing the code it can be kind of difficult but you don't need to replicate the code method
00:18:48.610 for method or anything but if reading the get logs without the code open makes sense then that history becomes a much
00:18:54.760 more useful document is there an external resource that applies link to a
00:19:02.289 ticket or a feature spec or user story PR comment slack discussions can be deep
00:19:07.990 linked resources that you use that's Stack Overflow answers blog posts videos
00:19:13.590 documentation specification conference talks from cool guys and bowties remember that links aren't forever the
00:19:20.770 message should still make sense we all refer to old code as a reference from
00:19:27.010 time to time how did I solve this the last time a little explanation and
00:19:32.320 you're leaving breadcrumbs about how a design pattern a library or technique worked or didn't work and you're able to
00:19:38.980 be one step ahead next time I've had a little success with tagging my messages
00:19:44.230 not gets tags plaintext tags to search either with github search box or with git log on the command line a little
00:19:51.669 example here I use this convention when it's some piece of work I might want to refer back to and I try to give it a
00:19:57.610 good name but you know only two hard problems so this is in a repo of code for a
00:20:03.659 workshop I led and I think what I need is near the beginning so I'm gonna log in Reverse I didn't see it there though
00:20:16.110 so we'll try to try to grip through it because this command is a regex after the equal sign we're gonna have to
00:20:23.070 escape the dollar sign and here's the syntax for that command by the way it's get logged - - grep equals what are you
00:20:30.179 looking for and there it is okay self
00:20:40.080 documenting completely self-contained context free code is an unrealistic myth and at worst it's an excuse not to try
00:20:48.740 even if you're using a tool like yard or Jas doc which I really like to generate
00:20:53.909 API documentation that's just adding more what and why we wrote some code one
00:21:00.630 way isn't necessarily going to be helpful for someone looking up what arguments of function takes so Y doesn't
00:21:06.510 really seem to go there but it can be helpful for someone who's making a change to this code API Docs and code
00:21:13.559 comments they don't stay in sync with the code as written but commit messages persist exactly the same length of time
00:21:20.460 as the code they describe because new code necessarily changes those commit
00:21:25.740 messages change your code update your Doc's for free so we've talked about why
00:21:33.480 we want to write better messages and how we can assemble a useful git history and it sounds like we're going to get to
00:21:39.450 know our way around some parts of get that might be unfamiliar because treating the commit history is a kind of
00:21:46.409 documentation requires a little more thought towards what commits that you leave behind
00:21:52.399 git has a lot of baked in tools to help us accomplish just that like message
00:21:58.200 template many of us are probably familiar with this message it's what appears when you start a new commit from
00:22:03.960 the command-line but this is customizable it doesn't have to be the same as this if a team has a standard of
00:22:10.890 what should be included in a message we can leave prompts for ourselves to fill in remember the default message any line
00:22:18.100 with the octothorpe will be ignored on line 12 we see closes to with an issue
00:22:24.970 number github will close the related issue once this commit is merged to the default branch bonus any of these
00:22:32.529 keywords actually work on github closed closes closed and if you don't use github many other tools have very
00:22:38.890 similar features as well this example has width guides in case we can't set a
00:22:45.159 hard wrap it also includes a reference to tags in the subject line this is a
00:22:50.860 convention popular and a lot of open source projects angular electron other places it's called convent it's called
00:22:58.840 conventional commits and I'm not really gonna touch on that here but the super simplified version is to make commit
00:23:04.269 messages both more human readable and helpful but also machine parsable
00:23:12.210 thank you okay until get where to find the template in the git config that's a
00:23:18.370 file that lives in the home directory or if you're on Windows looks something
00:23:24.130 like that there are plenty of configuration options that are possible in here but
00:23:29.919 the one that we're gonna care about right now is this commit in the brackets is the section heading template equals
00:23:35.409 and then the path to the file that you just made if this is the only configuration in the file that's totally
00:23:40.600 valid that let's commit templates you
00:23:47.740 can store those maybe you have a dot files management system something like that and if you want to geek out about that
00:23:53.529 in the hall afterwards I'll be there you know who you are sometimes small changes need to happen
00:23:59.740 after a commit whitespace fix or we want to change a variable name but we've written a really great commit message
00:24:06.580 insightful future aware comment what's
00:24:12.909 that gonna do for the messages for that file well this is kind of a contrived example okay but here's a bit of code we
00:24:20.470 see that there are some typos autocomplete makes that easy sometimes right it's valid code still but it's got
00:24:26.470 to be fixed if fix the typo and commit again what are the commit message is gonna look like if
00:24:31.840 you try to get blame or read through line by line in your editor good
00:24:37.360 messages on all the lines but the typos fix override it overrides it on some fairly important places sometimes there
00:24:44.140 are changes that aren't worth the commit message but there still needs to be a commit or maybe there's a commit that
00:24:50.950 you needed for development that doesn't need to be pushed up or merged right so
00:24:57.309 you don't have to retype copy/paste messages there's a command to merge commits and we can sweep that typo or
00:25:03.340 whip under the rug no one even needs to know whatever happened so if you've had
00:25:08.500 trouble with rebase in the past that's okay we don't need to really grok the concept in the same way with this
00:25:13.720 technique - i means this is interactive rebase and we're just gonna change
00:25:18.760 within our current branch so no none of that this allows us a lot of flexibility
00:25:24.070 and manipulating the commit history and it's done by opening a txt file in your chosen editor more on that in a minute
00:25:30.580 so this is the file that comes up it's going to serve as a set of instructions to get on how it should handle each
00:25:36.610 commit we see they're listed out in order oldest to newest first is the action that we want get to take for each
00:25:42.639 commit defaulting to pick second is the short form of the hash that acts as an ID for that commit and finally the
00:25:49.450 subject line of the commit message note here that the body of the messages are not displayed just the subject for now
00:25:55.870 so another reason why a descriptive subject line is important because try messing around at the get history with a
00:26:01.510 bunch of subject lines like some changes do model and hopefully the available
00:26:06.880 actions we can use are listed below and commented out portion I've kind of lightened some of them out because today
00:26:12.610 we're gonna cover just those four first up is pic it's the default action for
00:26:18.039 each commit and it basically means use this commit doesn't do anything replay it into the history just the way it is
00:26:24.750 next up is reword so use the commit but
00:26:30.549 edit the commit message let's take a look at what a reword action looks like in practice
00:26:37.919 so before we start let's take a look at the commits that we want to change it's the last commit relative to where
00:26:43.840 we are now so we use git log head tilde to mean show me the message on the
00:26:49.030 commit right before head where I am we don't need to memorize the content here to understand what happens next two
00:26:55.600 paragraphs you kind of roughly the shape of it you'll understand so let's continue on we'll use our git rebase - I
00:27:02.860 to get started and first step is to
00:27:08.140 change the text on the line of the commit that we want to reword then we're going to save and close the file it will
00:27:14.680 read in those instructions and procede
00:27:22.500 it opens the commit prompt same as if it was a brand new commit but pre-populated to the message that currently exists
00:27:28.780 we're gonna make a really obvious change here show what's going on okay we didn't
00:27:34.900 change the subject line there but we could if we wanted to and let's log out the same message and see what it looks
00:27:40.450 like now nice
00:27:48.130 I'll changed I'll superimpose the old log and as you can see the commit hash
00:27:53.170 has changed because the content of the commit changed with the message but the date everything else stays the same
00:28:00.390 next is squash I find it most useful for managing unnecessary commits or creating
00:28:07.150 commits that more succinctly encompass the work for a branch because sometimes
00:28:12.700 development needs more commits than we're going to need in master I'm
00:28:17.920 looking at these three commits it seems like they're kind of doing very similar things and I want to have the messages
00:28:23.170 and changes merged into one commit to push it up for code review what I want
00:28:31.480 to do is take the commits on lines three and four and merge them into the commit on line two so when you label a commit
00:28:37.480 for squashing it will be merged into the commit before it so remember that squashes move up and because the
00:28:47.710 contents of the commit has changed I want to change the subject to let's see
00:28:52.930 that a little bit in practice - well fire up our inter active rebase same as before but now we
00:28:59.980 choose squash save and quit say even
00:29:07.870 quit there it is the file that is opened is where we tell get what to do with the
00:29:13.420 messages as three commits become one each message is delineated with a
00:29:18.940 comment and each section consists of the commits subject a blank line and the
00:29:24.010 message if we did nothing the new commit message would look exactly like this but without the comments that doesn't seem
00:29:30.880 necessary to me to keep all the outdated subject so I'll remove the comments too so I can better see what the finished
00:29:36.280 message is going to look like and the
00:29:42.730 first line will become our new subject and since this doesn't accurately reflect what this commit is changing
00:29:48.010 we're gonna update that too we'll take a
00:29:57.160 look at the new commit now that we're all done I'm gonna use git log - - one line to see a compact version of the log
00:30:03.700 with only the subjects and copy that short hash to use for our get logging
00:30:09.130 it'll start the printout at the specific commit there it is finally fix up which
00:30:22.990 doesn't really need a whole run-through because fix up merges up just like squash but the commit message is just
00:30:28.570 deleted this is perfect for typos whitespace commits things like that so I
00:30:37.120 could literally spend another hour up here going through git commands and minutia so if you wanted more of that I
00:30:43.390 sincerely hope that you went to Chris tomb he's incredible deep dive into get workshop yesterday and as for me I made
00:30:50.740 a bold promise in the talk description that I would teach you how to do all of this get wrangling in an editor other
00:30:58.900 than vim I know this is why you're all here so I put it at the end ok first
00:31:06.500 I do want to show you how to use them just enough to not have to open another application see you can stay in the
00:31:13.730 terminal for all your message crafting needs ok git commit will likely drop you
00:31:19.190 into vim yes and that can be a scary place if you don't know all of the arcane incantations required but you can
00:31:25.909 handle committing and message editing with three commands nothing works the
00:31:32.600 way you're used to when you first get into vim that's because you're in a mode for navigating the text not editing to
00:31:40.340 edit you must enter insert mode press I to get into insert mode then you can
00:31:46.580 type and move around the way that you're used to even the arrow keys work here
00:31:51.669 when you're done editing you'll need to press escape I don't have a mnemonic for
00:31:57.169 that it's escape you cancel out of insert mode by pressing escape to
00:32:05.059 complete the process you'll type : WQ : to enter a command W to write and Q to
00:32:12.020 quit so all told that's I type your message escape : write quit now you know
00:32:21.110 vim but if you feel the need to use
00:32:29.030 another editor al we're gonna have to do is open up that git config and add another setting core as the heading
00:32:36.169 heading editor equals the command to open your editor from the command line
00:32:42.070 sometimes you're gonna have to install that command it should be in your editors FAQ or the like if you don't
00:32:48.020 already have that set up if you use a GUI editor definitely for atom vs code
00:32:53.240 or sublime you'll need to append - - weight to the command or it's only gonna open a blank file or you can just run
00:33:02.720 this command from the command line once if you don't want to setup a git config
00:33:08.110 so I am pretty close to out of time but I want to let you know that I'll be
00:33:13.640 tweeting out a copy of these slides as well as a post about all of the other things that I didn't get to cover
00:33:19.910 because after running my talk for the first time I realized it's about two hours long and some things just had to
00:33:27.320 go things like a mini review of my opinions on plugins for most of the
00:33:32.630 major editors and more useful git commands for reading and managing commit history I really like Kim so I apologize
00:33:41.240 for not being able to get it all together for you to be ready for today but we were woken up this morning by a
00:33:46.430 call from our doggy daycare that they had to rush my little boy here to the vet he's fine but it's obviously left me
00:33:52.520 with less time than I thought I had so not religious or anything but hugs at a
00:33:57.530 distance for Henson please so I hope that you have all formed or started to
00:34:03.320 form your own idea of what a good commit message is I think you'll find that the answer to how do we write good commit
00:34:10.250 messages is different for every team every person every situation well still
00:34:15.590 considering its usefulness I'm gonna close with my answer to that a line that
00:34:21.050 is very quickly becoming my personal catchphrase probably get it tattooed written on my gravestone maybe an next
00:34:28.160 railsconf I'll hire a skywriter the answer like the answer to most things is
00:34:33.790 with empathy empathy for your teammates empathy for yourself empathy for
00:34:40.880 developers of the future you might never meet someone earlier in the week said something that I absolutely loved when I
00:34:47.870 told them about my talk they called me a commit message archaeologist yeah so I
00:34:56.060 encourage you to be commit message archaeologists not the same time to leave something behind that can be
00:35:01.130 useful for fellow archaeologists and even if you can't convince everyone else
00:35:06.170 that you work with that commit messages should be more than uh-huh if you're one
00:35:13.640 in a team of five then taking up the mantle of meaningful commit messages still means that you'll have 20% more of
00:35:19.940 a chance that a commit message can save your bacon - and once your message saves someone else I'm willing to bet it'll be
00:35:26.900 a 40% chance soon after so I'll leave you with that thought and a paraphrased
00:35:32.510 quote thank you