Is there a git command that returns file encoding like file in Linux?
That completely describes my problem. I tried searching Google but found nothing.
Git itself has no idea of the encoding of a file (stored as a blob, meaning as an arbitrary binary data).
See "What is the format of a git “blob”?".
The command file can still be used after a git checkout.
Or piped after a git show to read the content of a specific file, e.g.:
$ git show @~2:README.md | file -
/dev/stdin: ASCII text
tells that the file ./README.md 2 commits ago had an ASCII encoding - notice the last dash (-) denoting STDIN.
While this command:
$ git show :README.md | file -
/dev/stdin: Unicode text, UTF-8 (with BOM) text, with CRLF line terminators
tells that the same file staged in git's 'index' is gonna be Windows encoded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With