I want to reset the contents of my working directory to match some revision without changing the commit my current branch is pointing to, as git reset
As jthill mentioned in his answer, in the general case git read-tree can do what you want:
git read-tree
-umcommit
If, however, you want to be able to checkout/reset a subdirectory instead of the entire tree, you'll need a somewhat more complex command:
git diff
--cachedcommit--subdir|git apply-R --index
Since this command is much longer than the previous, if you plan on using it frequently you'll probably want to set up an alias for it:
git config --global alias.reset-checkout '!f() { git diff --cached "$@" | git apply -R --index; }; f'
And use like:
git reset-checkout 451a9a4 -- path/to/directory
Or just:
git reset-checkout 451a9a4