Git lesson 3: view your history (log) and learn how to get help

Great work! In the last lesson you learned to use git add <filename> to add a file to the staging area of your repository, and then git commit to permanently save these changes. That cycle – make changes, add changes, commit changes – is fundamental to the Git workflow and we will revisit it several more times over the course of these lessons.

In this lesson you will learn how to look at your commit history and how to get help from Git.

Look at your Git log

As time goes by, you will make more and more commits to your repository and you may want to review your commits or identify a particular commit. The history of your commits is called the log, and you can view it with git log. Running this command in your project_repo repository will give the following output:

commit c585a2e75d0447fb2440f56d5b011b6e0974d9cd
Author: Martin Heroux <>
Date:   Wed Feb 17 20:18:56 2016 +1100

    Add doc.txt to repo on branch master

The first line contains a unique identifier for the commit you previously made (your identifier will be different to mine). In the future, you can use this identifier to refer to this commit.

The second line contains the name and e-mail of the person who made the commit. This is useful when two or more people work on a project and commit to a repository because you know who to contact if you have a question about a specific commit.

The third line lists the date of the commit; when a repository has more than one commit, the default is for git log to show you the commits in reverse order, from the newest to the oldest.

The last line of the log entry is the commit message you wrote when you made the commit. It should help you remember why you made the commit in the first place.

Although highly informative, the default format of git log can become a little overwhelming when your repository has dozens or even hundreds of commits (you will have to press spacebar to scroll through each page of the log, and q if you want to stop scrolling and get back to the command line). To get a quick overview of your commit history, you can use the slog alias we created in one of our previous lessons to show a more summarized version of your repository’s log:

21:01 ~/Desktop/project_repo$ git slog
* c585a2e Add doc.txt to repo on branch master

Now each commit in the log is printed on a single line, with the first 7 characters of the unique identifier and the commit message. This is a good time to mention that you will almost never have to refer to a commit by it’s entire unique identifier; the first 7 characters are enough for Git to figure out which commit you are referring to.

As you will soon discover, git log and git slog will be among your most frequently used Git commands.

Getting help with Git

When learning new skills, you may forget key details and have lingering questions. Fortunately, Git is well documented and you can access this help from the command line.

If you simply type git at the command line, you are presented with a categorized overview of Git commands.
Even more useful is the ability to type git help <command name> to get the full documentation for a particular git command. Although this documentation can be a little overwhelming at first, you will soon learn to love this resource.

For example, try typing git help commit on the command line and the hitting the Enter key.
You will be presented with the GIT-COMMIT page of the Git Manual, which provides the Synopsis, Description, Options, Examples, etc. for the commit command.

The Options section of the documentation is particularly useful. It lists and describes all the options (flags) that can be used to modify the functionality of the command. When navigating the Git Manual, remember that you have to use the up arrow and down arrow keys to move up and down 1 line at a time, the f and b keys to move forward and backward 1 full screen at a time, and q to quit and return to the command line.

If the in-built help is not enough (or is too cryptic at first), you can type your question into Google and you will find an answer to your question. If you prefer to look through a book and its Table of Contents, Pro Git is a free online book that is well illustrated and not overly technical.


You just learned how to view your repository’s history using git log and its alias git slog. You also learned how to find help on any Git command using git help <command name>. In the next lesson you will learn to use git diff to view changes made to a document, as well as review the core Git workflow cycle: make changes, add changes, commit changes.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s