status & log
Inspect your repo state and history
Skills taught: git.status, git.log, git.diff, git.show
git status
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: src/index.html ← STAGED
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
modified: src/style.css ← MODIFIED
Untracked files:
(use "git add <file>..." to include in what will be committed)
src/new-page.html ← NEW
# Short format — compact view
$ git status -s
M src/index.html ← staged (green M)
M src/style.css ← unstaged (red M)
?? src/new-page.html ← untracked
git log — view history
# Full log
git log
# Compact one-line per commit
git log --oneline
# a3f2c1d (HEAD -> main) Add dark mode toggle
# 8b9e4f2 Fix login button on mobile
# 2c1a5e8 Add user profile page
# With branch graph (great for visualising merges)
git log --oneline --graph --all
# Filter by author
git log --author="Prashant"
# Filter by date
git log --since="2 weeks ago"
git log --after="2026-09-01"
# Search commit messages
git log --grep="fix"
# Show what changed in each commit (patches)
git log -p
git diff — see what changed
# Unstaged changes (working tree vs staging area)
git diff
# Staged changes (staging area vs last commit)
git diff --staged
# All changes (working tree vs last commit)
git diff HEAD
# Compare two commits
git diff a3f2c1d 8b9e4f2
# See what a specific commit changed
git show a3f2c1d
# See diff for one file only
git diff HEAD -- src/index.html
Frequently Asked Questions
How do I search for a commit that introduced a bug?
Use git bisect — it binary-searches your history to find the bad commit. Start with git bisect start, mark the current commit as bad with git bisect bad, mark a known-good commit with git bisect good <hash>, then Git checks out the midpoint for you to test.
How do I see who last changed a line?
git blame <filename> shows each line with the commit hash, author, and date of the last change. In VS Code, the GitLens extension shows blame inline while you code.