git blame -w file.txt

Shows who last modified each line in file.txt, ignoring whitespace-only changes.

This command annotates each line in the specified file.txt with the most recent commit hash, author, and timestamp—ignoring whitespace-only changes thanks to the -w flag—so you can see who last modified each line while filtering out formatting-only edits.

When run, git reads the file’s history line by line, attributes each line to a commit, and displays the commit SHA, author name, and date; the -w option tells it to skip over lines that differ only in whitespace so that code moves or reformatting don’t obscure real changes.

You can use -L <start>,<end> to blame only a specific line range, -e to include author email, or -C/-M to follow code movement and file copies. Similar commands include git log -L <range>:<file> for detailed history of a section or git annotate as an alias for blame.

Related commands

Welcome to GitExamples!

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