git log
Show the commit history
What it does
git log lists the commits of the current branch from newest to oldest: hash, author, date and message. Long output opens page by page: scroll with the arrow keys, quit with q.
--oneline squeezes each commit into one line with a short hash and the title, -5 (or -n 5) keeps only the last five. --graph draws branches and merges, and --all shows every branch, not just the current one. Together they map the whole repository. Name a file to keep only the commits that changed it.
Syntax
git log
git log --oneline -<number>
git log --graph --oneline --all
git log <file>Examples
Show the last five commits, one per line
git log --oneline -5same as:
git log --oneline -n 5,git log -5 --oneline,git log -n 5 --onelinelog— commit history--oneline— one line per commit-5— only the last five
Draw a compact graph of all branches
git log --graph --oneline --allsame as:
git log --oneline --graph --all,git log --all --graph --oneline,git log --all --oneline --graph--graph— draw the branching--oneline— compact--all— all branches, not just the current one