# What changed in working dir vs last commit (unstaged)?
git diff
# What's staged (ready to commit)?
git diff --staged
# Difference between two commits:
git diff abc123 def456
# Difference between two branches:
git diff main feature-branch
-old line that was removed
+new line that was added
unchanged context line
git show HEAD # last commit
git show HEAD~1 # commit before last
git show abc1234 # specific commit by hash
HEAD is a pointer to the commit you're currently working from — usually the tip of the branch you're on. HEAD~1 means "one commit before HEAD".
A file has been committed. Modify it, then stage the change. The tests verify you have a staged diff ready to commit.
Click "Run" to execute your code.