【发布时间】:2018-09-09 20:56:29
【问题描述】:
我想查看一个旧版本的文件,所以我跑了
git show <commit-sha>:example.less > temp.less
将旧版本导出为temp.less。但是导出的文件最终会使用 UTF-16 编码(甚至认为 example.less 是 UTF-8 编码的)。
我尝试了--encoding=utf-8 和--encoding=utf8,但都没有成功。此外,如果可能的话,我想在我的 gitconfig 中设置它,而不是每次都输入它。
Windows 10
Git 2.15.0.windows.1
【问题讨论】:
-
“>”提示意味着您在 Windows 上?那么,哪个Windows?哪个混蛋? Windows 有很多不同的 git。对于 Win10,请尝试 chcp 65001。
-
请注意,Git 本身存储一个原始字节流。您可以随时使用
git cat-file -p <blob-hash-ID>访问原始字节流。然后由您决定使用您喜欢的任何工具对其进行转换。使用git show可能会或可能不会通过各种字节流到编码转换器运行 blob,具体取决于您的 Git 版本和其他详细信息。 (根据需要将 Git 版本和操作系统详细信息添加到您的问题中。) -
@torek 我已经编辑了问题
标签: git character-encoding git-config