Intermediate · 8 min · practise every command in the built-in terminal

Viewing History

See commit history

git log
git log --oneline           # Compact, one line per commit
git log --oneline --graph   # ASCII graph of branches
git log -n 5                # Last 5 commits
git log --author="Ana"      # Filter by author

See what changed

git diff                    # Unstaged changes vs last commit
git diff --staged           # Staged changes vs last commit
git diff HEAD~1 HEAD        # Compare two commits
git diff file.txt           # Changes in one file

Reading a diff

- old line (removed, shown in red)
+ new line (added, shown in green)

Show a specific commit

git show a1b2c3d

See who changed each line

git blame file.txt

Practice tasks

  1. View the commit history in one-line format
  2. Check what changes are unstaged with git diff
  3. View only the last 5 commits
  4. Compare your staged changes against the last commit

Commands in this lesson

Git & Version Control