Python for Entrepreneurs Transcripts
Chapter: Digging Further into Git
Lecture: The Git commit log

Login or purchase this course to watch this video and the rest of the course contents.
0:00 So far in this chapter, we've taken a look a lot of the commands that allow you to add changes to the staging area,
0:07 commit your code, push those changes up to other repositories, whether those are local or in the cloud.
0:12 As you start to accumulate all of these commits, it's often useful to go back and look at what previous changes were made,
0:18 for example, the Full Stack Python repository has almost 2000 commits, so if I want to see when I added a new page
0:24 or when I may have introduced some typos, I can just go back with another command we'll introduce in this chapter, which is "git log".
0:31 Back on the command line, in our course demos repository let's run "git log".
0:35 What we're seeing are all the changes made in reverse chronological order, by commit. If you press the space bar,
0:42 we'll continue to scroll through all the commits until we get to the original one, which will be much further down.
0:50 What if we only want to see commits that have happened say this year, we can use the "git log --after" and punch in the year, a month and a date,
1:00 and it will only give us the commits that have been made in 2017, so this is much shorter list and we'll run out and get to the end pretty quickly.
1:08 so again that's a "git log --after", you can also use "before", and then you punch in a date by the year, month and day.
1:18 And that will give you everything before or after a specific date. When we use "git log", we are only seeing a short summary
1:25 with the author of the date and the commit message, what if we want to see more detailed information about the specific files
1:32 that have changed, well, if we want to see all the details, we can use the "git log -p" command, and this will give us the low level changes,
1:41 every single one of them the difference between the old file and the new that has changed in this specific commit, but this is pretty overwhelming,
1:49 so instead of using "git log -p" typically, most developers use the --stat argument. This will give you at a glance all the files that have changed
2:00 and roughly how many changes were made to those files, so this is much easier to scroll through and see what has changed
2:07 over the past few commits. Using "git log" without any arguments, will give us the laundry list of the author, the date and the commit title
2:15 for every single commit, the -p flag will give us absolutely everything about each commit, the --stat argument gives us a hybrid with all the files
2:25 that have changed, and if we want to see a really condensed version of all of our commits, we can use the --oneline argument,
2:32 this is going to give us a very condensed version of just the last seven hex digits in a commit,
2:40 and then the title for that commit, and you can see why commit messages are so important, because eventually, you will have a laundry list
2:48 of these throughout the entire history of your project and it's going to be really useful for you and anyone else that you're working with
2:54 to be able to see everything at a glance. That is the "git log" command, and some of the common arguments
3:00 that you'll use after you start building up your commit history.


Talk Python's Mastodon Michael Kennedy's Mastodon