I have a local git repository, and I need to do the equivalent of a TFS 'Undo Pending Changes'. There is no remote repository. There are no branches, just Master. I have tried nearly every suggestion from questions "How to checkout only one file from git repository" and "Undo working copy modifications of one file in Git". When I do '$ git checkout HEAD -- error.cshtml', I always get "error: pathspec 'error.cshtml' did not match any file(s) known to git." How can I get the latest committed version of a single file from the repository?
Asked
Active
Viewed 78 times
0
-
Are you sure the file is actually in the repository? Does `git log --oneline -- error.cshtml` produce any output? – zetetic Jun 01 '15 at 18:56
-
also check the directory you're executing command – manzur Jun 01 '15 at 19:55
-
Is the file in the root of your repo? Of is the file in a subdir? If the latter, you need to use the full path from the dir you execute the command: `git checkout HEAD -- path/to/error.cshtml`. – Waylan Jun 01 '15 at 20:27
-
That was it @Waylan, the file was a few subdirs down. I thought checkout would recurse through the repo. Thank you. – JNygren Jun 02 '15 at 21:09