Inspecting History
How to use `git log` to travel back in time and understand what happened, when, and by whom.
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.
Remember this
git logshows your commit history.- Press
qto quit the log viewer. - Use
--onelinefor a condensed view.
Done with this concept?
Mark it complete to track your progress. No login needed.