reset, checkout, revert
When invoked with a file path,
git reset updates the staged snapshot to match
the version from the specified commit. For example, this command will fetch the
foo.py in the 2nd-to-last commit and stage it for the next commit:
git reset HEAD~2 foo.py
As with the commit-level version of
git reset, this is more commonly used with
HEAD rather than an arbitrary commit. Running
git reset HEAD foo.py will unstage
foo.py. The changes it contains will still be present in the working directory.
--hard flags do not have any effect on the file-level
git reset, as the staged snapshot is always updated, and the working
directory is never updated.