Inspecting History

How to use `git log` to travel back in time and understand what happened, when, and by whom.

Version Control4 min readConcept 6 of 29

git log

git log is the command you use to view the commit history of your repository. It prints out a chronological list of every snapshot ever taken, starting with the most recent.

By default, it shows the commit hash, the author, the date, and the commit message.

Why it matters

If you join a new project, git log is how you read the story of the codebase. You can see who wrote what code, when features were introduced, and trace back exactly when a bug first appeared.

Without it, you just have a folder of files with no context.

Formatting the output

The default git log output is very verbose and can be hard to read on large projects. Git provides powerful flags to format this output.

The most common is git log --oneline, which condenses every commit into a single line showing only the first 7 characters of the hash and the commit message.

You can also use --graph to draw a text-based representation of branching and merging on the left side of the terminal.

Check yourself

Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.

  1. 1What is the primary purpose of `git log`?
  2. 2If you are stuck viewing a very long `git log` and see a `:` at the bottom of your terminal, how do you exit?
  3. 3What does the `--oneline` flag do when added to `git log`?

Remember this

  • git log shows your commit history.
  • Press q to quit the log viewer.
  • Use --oneline for a condensed view.

Done with this concept?

Mark it complete to track your progress. No login needed.