Git History allows you to explore how a project has evolved over time by examining commits, messages, authors, and changes. It helps track progress, debug issues, and understand collaboration flow.
The primary command for inspecting history is git log. It provides chronological details of commits starting from the most recent.
// Show complete commit history
git log
// Limit history to last 5 commits
git log -5
// View history with branch graph
git log --graph --oneline
// Search commit messages containing keyword
git log --grep="authentication"
// Show changes introduced in a specific commit
git show <commit-hash>
// Checkout a previous commit temporarily
git checkout <commit-hash>
// View history of a specific file
git log <file-name>
The output of Git history commands includes commit hashes, authors, timestamps, and messages. Graph mode visually shows branch merges, making collaboration easier to understand.
Try running git log --graph --oneline --all in a repository with multiple branches to visually explore how branches diverge and merge.
--oneline for readabilitygit log in any repository--grepgit show