This does exist, but it's actually a feature of git log:
git log -p [-m] [--follow] [-1] <path>
Note that -p can also be used to show the inline diff from a single commit:
git log -p -1 <commit>
Options used:
- -p(also- -uor- --patch) is hidden deeeeeeeep in the- git-logman page, and is actually a display option for- git-diff. When used with- log, it shows the patch that would be generated for each commit, along with the commit information—and hides commits that do not touch the specified- <path>. (This behavior is described in the paragraph on- --full-diff, which causes the full diff of each commit to be shown.)
- -mcauses merge commits to include the diff content (otherwise these just show the commit message, as if- -pwere not specified).
- -1shows just the most recent change to the specified file (- -n 1can be used instead of- -1); otherwise, all non-zero diffs of that file are shown.
- --followis required to see changes that occurred prior to a rename.
As far as I can tell, this is the only way to immediately see the last set of changes made to a file without using git log (or similar) to either count the number of intervening revisions or determine the hash of the commit.
To see older revisions changes, just scroll through the log, or specify a commit or tag from which to start the log. (Of course, specifying a commit or tag returns you to the original problem of figuring out what the correct commit or tag is.)
Credit where credit is due:
- I discovered log -pthanks to this answer.
- Credit to FranciscoPuga and this answer for showing me the --followoption.
- Credit to ChrisBetti for mentioning the -n 1option and atatko for mentioning the-1variant.
- Credit to sweaver2112 for getting me to actually read the documentation and figure out what -p"means" semantically.
- Credit to Oscar Scholten for pointing out that by default, -pdoes not show diff-contents for merge commits.