Getting Git

A comprehensive video course from git init to Git Master.

Part 2 - Summary


This completes Part 2.

I'll admit, with the exception of git status you may not use these commands very often.

Nonetheless, they helped familiarize us with commits and some of their terminology.

In addition, they're useful for viewing history.

So to demonstrate I've cloned one of the trending repositories on GitHub.

We'll learn how to use git clone in Part 4. For now, I just wanted an unfamiliar repository so we can use these commands to learn more about it.

Just a reminder I go quicker in the summary videos.

Don't feel like you need to follow along. I'd rather you focus more on how the commands are used.

First, I want to get a feel for the repository.

So, I'll run:

git log --oneline

This gives me a sense of the commits and overall project. However these two aren't always related.

You can make a lot of commits in a short amount of time, or a few commits over a long time.

There's a lot of commits, so I'm going to type q to quit.

Instead, let's figure out what's been changing recently.

I'll do so by running:

git log --oneline --name-status -10

This shows me the most recent 10 commits and the files that were changed within them.

Seems like the README file changes a lot. This makes sense because if I run ls it's really the only file in the repository.

Let's use git diff to see how it's been changing.

I'll grab one the oldest commit SHAs from git log and pass it to git diff follow by ..HEAD.

Remember, by passing the older commit first in the range, we get a more natural output from git diff as it will travel forward through the changes instead of backwards.

Looks like they're adding lots of code samples.

I'm curious what the README file looked like on the very first commit.

To find out, I'll determine the first commit SHA and pass it to git show.

One of the many additional options for git log is --reverse. This shows me the commit log in reverse chronological order. So the oldest commit is first.

So, I'll run:

git log --reverse

I see this is the first commit so I'll copy the commit SHA and pass it to git show followed by :README.md

And here's what the README file look like at the very first commit.

Seems it's come a long way. No wonder it's a trending repository on GitHub.

So that completes Part 2. While we might not use git diff or git show much more, we will definitely continue to use git status in every video and git log more in Part 3.