Loading lessons...
Git Log and History
Git Log and History
git log shows the commit history of your repository.
View your history
git log
The output lists commits from newest to oldest. For each commit it shows:
- the hash (long ID),
- the author,
- the date,
- the commit message.
A compact view
git log --oneline
This prints one short line per commit, showing a shortened hash and the message. It is the fastest way to skim history.
Limit the output
git log --oneline -5
The -5 shows only the last 5 commits.
See what changed
git log -p
The -p (patch) option shows the actual code changes in every commit. Use it to see exactly what each commit did.
Quit the log
git log can be long. Press q to get back to your terminal prompt.
TL;DR
git logshows full history, newest first.git log --onelineshows a compact summary.git log -5limits the number of commits.git log -pshows the code changes too.