Understanding history helps you reason about changes and collaborate effectively.

  1. View commit history
  • git log --oneline --graph --decorate --all
  • git log --stat
  1. See a specific commit
  • git show HEAD
  • git show <commitSHA>
  1. Compare changes
  • git diff # unstaged changes
  • git diff --staged # staged vs last commit
  • git diff main..feature/x
  1. Limit and search logs
  • git log -n 5
  • git log --author="Your Name" --since="1 week ago"
  • git log -S "search-term" # pickaxe search by added/removed text

Checklist

  • You can read git log output
  • You can show a specific commit
  • You can diff unstaged and staged changes