Table of Contents
Git History
Commit history is the record of all changes to your project. Use git log to view it, git show or git diff to see what changed, and git blame to find who changed each line and why. Understanding history helps you debug problems, understand design decisions, and audit who made what changes.
The simplest way to explore is git log --oneline to see a compact list of recent commits, each with its hash and message. For more details, git log --stat shows which files changed in each commit. git show <hash> displays the full diff of a specific commit, including its message.
$ git log # view full commit history $ git log --oneline # compact view with one line per commit $ git log --stat # show file statistics for each commit $ git log -p # show full diff for each commit $ git show <hash> # view a specific commit's changes $ git blame <file> # show who changed each line $ git diff <hash1> <hash2> # compare two commits
git blame is particularly useful when you find a suspicious change—it shows the commit hash, author, date, and the line in question. Use git log -p <file> to see the history of changes to a single file, which often makes it easier to understand why something was done.
