Git Log
Part of the Version Control section of Coddy's Terminal journey — lesson 13 of 58.
Once you have made commits, you can browse the history with git log:
git logIt shows each commit with its full ID, author, date, and message, newest first. That is a lot of output for browsing, so most people use the compact form:
git log --onelineThis prints one line per commit: a short ID followed by the subject:
a1b2c3d Add first task
9f8e7d6 Add todo listUseful flags include:
-n 5: show only the last 5 commits--oneline: compact one-line-per-commit format--reverse: flip the order so the oldest commit appears first
The list of subjects alone is often the fastest way to remember what you have been working on.
Challenge
EasyThe folder contains todo.txt. Initialize the repo, configure user identity, then create two commits in order:
- Stage and commit the file with the message
Add todo list. - Append the line
buy milktotodo.txt, stage it, and commit with the messageAdd first task.
Then print the history with git log --oneline.
Cheat sheet
Browse commit history with git log:
git logCompact one-line format (short ID + message):
git log --onelineUseful flags:
-n 5— show only the last 5 commits--oneline— one line per commit--reverse— oldest commit first
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
2Getting Started
Initialize A RepositoryThe .git FolderConfigure Your IdentityGit StatusRecap - First Repo8Merging
What Is A MergeFast-Forward MergeThree-Way MergeMerge ConflictsResolve A ConflictRecap - Merge Master11Feature Branch Project
Project OverviewInitialize Main3Tracking Changes
The Staging AreaGit AddGit CommitModifying A Tracked FileGit LogRecap - First Commits6Recipe Site Project
Project OverviewInitialize And Ignore