Git: View History/Log

By Xah Lee. Date: . Last updated: .

How to get a history of commits?

git log -3 -- filepath
show last 3 commits of a specific file.
git log -3
show last 3 commits.

This command is important because it shows the Commit ID . You'll need to use the ID when doing git diff or other git operations. .

git log 2022-11-17 BVYCw
git log 2022-11-17

How to see last change?

git log -p -2 --color -- filepath
show diff in last 2 commits of file.
git log -p -2 --color
show diff in last 2 commits.

-p or --patch means generate patch diff format.

git log diff 2022-11-17 ctr4M
git log diff

git help log