If I want to see how foo.bar
looked like in some certain commit
then I can invoke:
git show :foo.bar
There's a package called git-timemachine that makes the process of viewing previous versions of a file almost completely seamless; see the link for installation instructions and a demo. (If you are already using MELPA, just do M-x package-install
RET git-timemachine
RET).
The way it works is, you call M-x git-timemachine
RET from a buffer visiting a tracked file. Then you can:
p
Visit previous historic versionn
Visit next historic versionw
Copy the abbreviated hash of the current historic versionW
Copy the full hash of the current historic versionq
Exit the time machine.
Note that if you know the hash of the commit you want to visit, the custom command from @phils' solution will serve you better for that specific use case. But for navigating between different versions of a file I find that using git-timemachine
is even easier than using the functionality that VC provides.
You can of course bind git-timemachine
to a key binding of your choice.