Viewing History
One of Git's superpowers is letting you travel through time. Every commit is a snapshot you can inspect, compare, or return to.
âšī¸Repository ready
We've prepared a repository with 4 commits for you to explore.
Your Commit History
No commits yet.
Try These Commands
Use the Terminal to explore history. Follow the steps to see different views of the same commits.
Steps
1
View Full History
See each commit with full details.
Show the full log:
git logThis shows hash, author, date, and message for each commit.
In VS Code
Open the Source Control tab and scroll to the Graph section to see the same commits visually.
2
Compact View
Scan history quickly.
3
Inspect a Commit
Look at a single commit in detail.
4
Compare Commits
See what changed between two commits.
đģ Terminal
Terminal â /
Repository with 4 commits ready.
Try: git log
$
đ VS Code
Explorer
No files yet.
Click + to create a file.
Click + to create a file.
Select a file to edit
Useful git log Options
git log --onelineCompact one-line view
git log --graphASCII graph of branches
git log -pShow changes in each commit
git log -n 5Show only last 5 commits
git log --author="name"Filter by author
git log --since="2 weeks ago"Filter by date
Referencing Commits
| Reference | Meaning |
|---|---|
| HEAD | Current commit (where you are now) |
| HEAD~1 | One commit before HEAD (parent) |
| HEAD~3 | Three commits before HEAD |
| abc1234 | Specific commit by hash (first 7 chars) |
| main | Latest commit on the main branch |