"piping" and "redirecting output" in Powershell is a bit of a mess, and doesn't work as in bash (some would simply say : doesn't work).
You can read the answer to the question suggested by @iRon :
Changing PowerShell's default output encoding to UTF-8
Depending on your settings :
- if the file does not begin with a
BOM
, powershell may try to convert the bytes in the input stream as if they were ASCII text, to a target encoding,
- if you don't tweak your powershell settings, the target encoding defaults to
UTF16
,
- even when you set the default output encoding to
UTF8
, I was never able to get rid of the BOM
that it would so helpfully insert at the beginning of the output,
- etc ...
Bottom line is :
- if you want to "extract a file" using
git show commit:file > content
, stick to bash.
- another way to have both versions, of course, is to rename the current version of the file, and run
git checkout commit -- file
.
Quoting the other answer : there seems to be a "Powershell Core" edition which should fix most of these problems ; I wasn't fortunate enough to have this version at hand when I was working with Windows ;)