1. Viewing History and Diffs
git logWhat it doesDisplays detailed commit history with the author name, date, and message
When to use itto review the full history of the current branch
Example
git loggit log --oneline -10What it doesOne-line summary history for each commit of the last 10 records
When to use itto take a quick look at your recent edit history
Example
git log --oneline -10git log --oneline --graph --decorate --allWhat it doesDisplays a visual tree showing the branches and merging of all branches
When to use itto understand the structure of complex history and the paths of parallel branches
Example
git log --oneline --graph --decorate --all -15git show <commit>What it doesChecks details, content and edits (diff) for a specific commit or tag
When to use itto see exactly what was changed at a version or point in time
Example
git show v1.0.0git diff HEADWhat it doesCompares the entire Working Tree with the last commit in HEAD
When to use itto see all remaining changes compared to the last commit
Example
git diff HEADgit diff --checkWhat it doesDetects whitespace and trailing line errors before committing
When to use itto avoid unintentional formatting errors in reviews
Example
git diff --checkgit blame <file>What it doesidentifies the last commit and person who changed each line in the file
When to use itto know the context and date of writing a specific line of code
Example
git blame src/server.ts