How to view Git commit history

· Category: Git

Short answer

Use git log to display the commit history of the current branch.

Steps

  1. View basic commit history:
git log
  1. View compact one-line history:
git log --oneline
  1. View graphical history:
git log --oneline --graph --all
  1. View file-specific history:
git log --follow -- filename.txt

Tips

  • git log --stat shows changed files and insertion/deletion counts.
  • git log -p shows the actual diff for each commit.
  • git log --author="name" filters by author.

Common issues

  • Very large history: use --max-count=20 to limit output.
  • Merge commits cluttering the view: use --first-parent to follow only the main line.