Displaying A Repository's Commits

TIP: In lesson 2 you usedgit cloneto clone the blog project. This is the project we'll be using in this lesson. If you skipped cloning the project in the previous lesson, then run the following command to get the project:

$ git 
clone
 https://github.com/udacity/course-git-blog-project

Don't forget tocdinto the project after you've cloned it.

Got questions about this, check out theClone An Existing Repo conceptor ask it in theforums!

QUESTION 1 OF 7

After you’ve cloned the blog project repository, navigate to the project’s directory using the command line. Once you’re located inside the blog project, what is the very first thing you should do in a Git repository?

  • run thegit statuscommand

  • open the project in a code editor

  • decide what new feature to work on

SUBMIT

The Terminal application showing the output of thegit statuscommand.

Git Status & Opening The Project

You can see thatgit statustells us that there's "nothing to commit, working directory clean". That means we're good to go ahead and check out the project!

So open the project in your favorite code editor. If you haven't yet, take a minute or two to look at the project – look over the CSS and the JavaScript files, but look particularly at the HTML file.

The course's Blog project open in a code editor. Theindex.htmlfile is being displayed.

QUESTION 2 OF 7

In theindex.htmlfile, take a look at the<h1>Expedition</h1>heading around line 15.

Based on what you can see here when was that heading added?

  • It was added on a Tuesday. Yeah, a Tuesday.

  • 3 weeks ago

  • ¯_(ツ)_/¯ I can't tell that by looking at the code.

SUBMIT

QUESTION 3 OF 7

Ok, so we're not quite sure_when_the heading was added. How about an easier question -_who_added this heading? Again, what can you tell from just looking at the code?

  • Richard did!

  • No clue

SUBMIT

The Git Log Command

Finding the answers to these questions is exactly whatgit logcan do for us! Instead of explaining everything that it can do for us, let's experience it! Go ahead and run thegit logcommand in the terminal:

$ git 
log

The terminal should display the following screen.

The Terminal application showing the output of thegit logcommand.

If you're not used to a pager on the command line, navigating inLesscan be a bit odd. Here are some helpful keys:

  • to scroll down , press
    • j or to move _down _one line at a time
    • d to move by half the page screen
    • f to move by a whole page screen
  • to scroll up , press
    • k or to move _up _one line at a time
    • u to move by half the page screen
    • b to move by a whole page screen
  • press q to quit out of the log (returns to the regular command prompt)

Git records_a ton_of information when a commit is made. See if you can usegit logto answer the following questions!

QUESTION 4 OF 7

Usegit logto find the commit that has a SHA that starts withf9720a. Who made the commit?

  • James Parkes

  • Richard Kalehoff

  • Colt Steele

  • Julia Van Cleve

  • Godzilla McFiddlebrunches

SUBMIT

What Is The Message?

Usegit logto find the commit with the SHA that starts with8aa6668. What is the message for that commit?

SUBMIT

QUESTION 6 OF 7

Usegit logto find the commit with the SHA that starts withf9720a9. When was that commit made?

  • Mon Dec 5 10:25:22 2016

  • Mon Dec 5 10:11:51 2016

  • Sat Dec 3 16:09:00 2016

  • Fri Dec 2 16:58:27 2016

SUBMIT

What Is The SHA?

Usegit logto find the commit that has the messageSet article timestamp color. Which commit belongs to that SHA? Provide the first 7 characters of the SHA.

SUBMIT

Git Log Recap

Fantastic job! Do you feel your Git-power growing?

Let's do a quick recap of thegit logcommand. Thegit logcommand is used to display all of the commits of a repository.

$ git log

Bydefault, this command displays:

  • the SHA
  • the author
  • the date
  • and the message

...of every commit in the repository. I stress the "By default" part of what Git displays because thegit logcommand can display a lot more information than just this.

Git uses the command line pager, Less, to page through all of the information. The important keys for Less are:

  • to scroll down by a line, use j or
  • to scroll up by a line, use k or
  • to scroll down by a page, use the spacebar or the Page Down button
  • to scroll up by a page, use b or the Page Up button
  • to quit, use q

We'll increase ourgit log-wielding abilities in the next lesson when we look at displaying more info.

Why wait?!? Click the link to move to the next lesson!

results matching ""

    No results matching ""