I've tried:
git checkout c3e715e -- file
git reset c3e715e -- file
Both times, if I git log
afterwards, I still see the log as if it never reset.
I've tried:
git checkout c3e715e -- file
git reset c3e715e -- file
Both times, if I git log
afterwards, I still see the log as if it never reset.
The "--" is not needed needed.
Just do checkout by providing the file name:
git checkout c3e715e filename
Also please make sure that you don't have any pending changes on that file before running the command.
Some notes (just in case you're interested)
There is a slight difference between checkout
and reset
.
Regarding the reset:
When invoked with a file path, git reset updates the staged snapshot to match the version from the specified commit.
In case of checkout:
Checking out a file is similar to using git reset with a file path, except it updates the working directory instead of the stage. Unlike the commit-level version of this command, this does not move the HEAD reference, which means that you won’t switch branches.
For more details see the last section of this article.