git log --follow -- <pathname>

Show the commit history for a single file, including before it was renamed or moved.

This command lets you see the full history of changes for one specific file, even through renames or moves, so you can trace how and why it evolved over time.

This command runs git log (which shows commit history) but limits the output to changes that affected the file given by <pathname>, and the --follow flag tells Git to keep tracking the file’s history across renames instead of stopping when the file name changes; the -- separates options from the path so Git knows <pathname> is a file path (for example src/app.js) and not another flag. Without --follow, git log -- <pathname> would only show history for the current file name, so you would miss commits from before it was renamed or moved.

You can extend this command with other useful flags, such as git log -p --follow -- <pathname> to see the actual line-by-line diffs for each commit, git log --stat --follow -- <pathname> to show per-commit change statistics, or git log --oneline --follow -- <pathname> to get a compact one-line-per-commit summary; you can also combine options like git log --oneline -p --follow -- <pathname> for a more detailed yet readable history, or add --author=<name> / --since=<date> to filter who changed the file and when.

Examples:

  • git log --follow -- src/app.js
  • git log -p --follow -- src/components/Button.tsx
  • git log --oneline --follow -- README.md
Manual page
git log
Related commands

Welcome to GitExamples!

Sign in to enable bookmarking, reminders, progress-tracking and more...