The problem with
git checkout 1f1d3f76bac0bf6e13ceee5bb3df69f8389fc73f -- /path/to/MyMissingFile
is, presumably based on what you said, it's the hash of the commit that deleted the file - so the file isn't there. But the file is in that commit's parent. You can use an abbreviated hash, by the way, and then tacking ^
or ~
onto the end will get the commit's parent. So
git checkout 1f1d3f76ba^ -- /path/to/MyMissingFile
should work. (There would be a potential bit of room for error here if the commit in question is a merge, in that you'd need to make sure you were reaching into the correct parent; but it sounds like that doesn't apply here.)
Switching to the newer restore
command is also an option (and probably not a bad idea), as someone else mentioned; but that isn't really the issue at hand.
As you seem to have discovered, you also could reach over into master
(or any other branch where the file still exists) and grab the file from there. I don't recommend this, though (especially if you've already gone to the trouble of finding the commit where the file was deleted), because (a) any changes to the file on your branch before its deletion are lost, and (b) any changes to the file on master may be prematurely picked up on your branch. Maybe you know those problems don't apply this time, but it's a bad habit. Next time maybe there's a change you forgot about.