Developer Productivity git log
Transcript from the "git log" Lesson
>> I want to show you one really awesome thing before we're just kind of we're done here. So let's go to refactoring and have you ever had a problem where you want to know how something's changed in your system over time, right? It's not that simple, say you have a class that is used throughout your system and you just want to see, hey, how's it been used throughout time?
[00:00:20] So a lot of people don't know too much about get log, get log's fantastic, right? So anyway, so we do get logged, right and what you can do is you can actually provide something called a dash s, a dash s will search in the commits. And if the thing you put in there exists within the diff, it will capture that commit.
[00:00:37] So I'm in a refactoring branch, if you do not know what we're refactoring it, it's named after the book by Martin Fowler, Refactoring. 106 stands for exact function, so when I do a 106, I can see every single commit that was related that contained the numbers 106 inside of it.
[00:00:53] So even though there's 153 commits, I think 157 will now like 158 after the 180, my goodness. After that last little test commit I did, I can actually see them and I can follow a commit. Is that one line, is it one line, there we go, I can just see only the commits that contain a diff that contains that phrase.
[00:01:16] So, if I wanted to go see a say a class, I'm curious how this one class has moved throughout our system, say in the last five commits. You could just put that class in there and see all the commits and walk through each one of them. And because I use vim by the way, I can actually use GC log, and I can do this and then I get it into a quick fix list.
[00:01:36] Which looks even better because then I can just walk through those commits like that. Now that is like some serious by the way, right there, all right, that's pretty fantastic. So you can actually walk through all those commits really quickly, so I want to kind of give you that Tic Tock style tip right here.
[00:01:50] Because I just find this to be super useful, this search thing, my goodness, it's just so great, right? Because sometimes you just have a weird behavior and you just kind of want to see how things have been used and changed over time. I love doing that, it also gives me really good perspective into the system.
[00:02:05] How it's been used, where it's been used and why it's being used and how it's being changed, fun fact bonus content, all right hand raised
>> That searching the git commit the log message or the actual commit
>> The actual commit, so look at this one, this one says refactoring testing, right?
[00:02:58] And so I believe that is what's causing it is because there is a 106 right in there. One of these files are all existing in some repo named 106 or this right here. It's one of the two either I've mentioned it right there or it's a file being changed with 106.
[00:03:11] I can't remember if it's one or the other, but either way it appeared in the diff, and so therefore, it's being flagged. And so for me, that's super cool, I'm pretty sure it's actually only the diff here, we can actually just check right now, man get log dash s.
[00:03:28] Look at the difference that changed the number of currencies in the specified [INAUDIBLE]. Let's see, yeah, okay, the additions and deletions, there we go, it's useful when you're looking for an exact block of code, right? And you want to know the history of that since it first came into being, so it's like a really cool kind of fun thing.
[00:03:43] I just think it's great, I love those, I love those kind of little tricks, they feel super sweet. And every now and then they will save your bacon and you just need to note that one time, right, it's like CPR. You only need it when you really need it, and when you really need it, you're happy to have it