git show [SHA OF COMMIT]:[FILEPATH] > [NEW LOCATON]
should be the right syntax.
But [FILEPATH]
should be the path from the root of the repo, not the absolute file path form the host drive disk.
From gitrevisions
man page:
<rev>:<path>, e.g. HEAD:README, :README, master:./README
A suffix :
followed by a path names the blob or tree at the given path in the tree-ish object named by the part before the colon.
:path
(with an empty part before the colon) is a special case of the syntax described next: content recorded in the index at the given path.
A path starting with ./
or ../
is relative to the current working directory. The given path will be converted to be relative to the working tree’s root directory.
In your case:
cd /d D:\Test\MyRepoFolder
git show a2f3f51ee27d5711d2974f0256b4eed0b3225d44:test.css > anotherpath\test.css
You would use :test.css
, not :D://...
(the absolute file path).
The root of the repo is "D:\Test\MyRepoFolder
".
Hence, the path to access test.css
should relative to that root.
In the OP's instance, the exact path of the file was ReactiveUI\afile
, and the repo was in D:\Test\ReactiveUI
hence a bit of confusion.
Even though the root folder was named ReactiveUI
, the command to use was:
git show <sha1>:ReactiveUI/afile
(with '/
', not '\
', as it is interpreted by the Linux git bash)
That is, "the path relative to the root folder of the repo".
Note: the ProcessInfo
class used by the OP does not support well the '>
'.
The export of the git command output has to be done programmatically.