What I ended up doing was a git checkout HEAD -- path/to/file
which, as I understand it, replaced the file with the one from the HEAD commit's tree, rather than checking in the index first.
I came up with this solution without consulting the git
man pages, but thanks to @torek for pointing out the git-checkout(1) man page. It was the fifth form of git checkout
that I used, which looks like this:
git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...
Part of the documentation for that form says:
The <tree-ish> argument can be used to specify a specific tree-ish (i.e. commit,
tag or tree) to update the index for the given paths before updating the working
tree.
So what actually happened was this: git replaced the file in the index with the version from HEAD (effectively removing the file from the index), then replaced the file in the working tree with the version from the index, eliminating the changes.