Viewing History With Git Log

To see the history of commits, use the command git log. It provides a list of all of the commits made on our branch with the most recent commit first. You aren’t stuck with the default behavior - try these log commands to view history in different ways.

  1. Type git log.
  2. Press q. You can press the up or down arrows or press enter to view additional log entries. Type q to quit viewing the log and return to the command prompt.
  3. Type git log -5 to only see the last 5 commits.
  4. Type git log --oneline.
  5. Type git log --oneline --graph.
  6. Type git log --oneline --graph --decorate.
  7. Type git log --oneline --graph --decorate --all.
  8. Type git log --stat.
  9. Type git log --patch.
Show me how
gif of the activities from this page
Tell me why

More About Git Log

There are lots of ways to customize the output from the git log command. We will just explore a few, but you can find many more on the website.


  • Git log has a great deal of information, but it is a little verbose. If you would like to see a condensed version, add the –oneline option.


  • The log command has many options and you can actually string them together to create a view that is most helpful for your situation. For example, you can add an ASCII graph of the branch and merge history of our project by adding the option –graph.


  • If you would like more information about the branches and where HEAD is located, you can add the –decorate option.


  • If you also want to include un-merged branches, you should add the option –all.


  • If you would like to see which files were involved in each commit, use the –stat option.


  • If you would like to see the actual changes that were made, use –patch.
Stuck? Open an issue in the repository for this class and mention @githubteacher for help from one of the GitHub trainers!