我一直在关注本指南在这里 https://git-scm.com/docs/gitattributes#_performing_text_diffs_of_binary_files关于如何区分 Microsoft Word 文档,但我遇到了以下错误:
Usage: /usr/bin/docx2txt.pl [infile.docx|-|-h] [outfile.txt|-]
/usr/bin/docx2txt.pl < infile.docx
/usr/bin/docx2txt.pl < infile.docx > outfile.txt
In second usage, output is dumped on STDOUT.
Use '-h' as the first argument to get this usage information.
Use '-' as the infile name to read the docx file from STDIN.
Use '-' as the outfile name to dump the text on STDOUT.
Output is saved in infile.txt if second argument is omitted.
Note: infile.docx can also be a directory name holding the unzipped content
of concerned .docx file.
fatal: unable to read files to diff
为了解释我是如何出现这个错误的:我创建了一个.gitattributes
在我想要区别的存储库中。.gitattributes
看起来像这样:
*.docx diff=word
*.docx difftool=word
我已经安装了docx2txt。我在Linux上。我创建了一个名为docx2txt
其中包含:
#!/bin/bash
docx2txt.pl $1 -
I $ chmod a+x
docx2txt 我把 docx2txt 放入/usr/bin/
.
I did:
$ git config diff.word.textconv docx2txt
然后我尝试比较两个 Microsoft Word 文档。就在那时我收到了上面提到的错误。
我缺少什么?我该如何解决这个错误?
PS:我不知道我的 shell 是否可以找到 docx2txt 因为当我这样做时:
$ docx2txt
我的终端冻结,处理某些内容,但不输出任何内容,当我执行这些命令时,会发生这种情况:
$ man docx2txt
No manual entry for docx2txt
$ docx2txt --help
Can't read docx file <--help>!
更新进度:我将 docx2txt 更改为
#!/bin/bash
docx2txt.pl "$1" -
正如 pmod 建议的那样,现在git diff <commit>
从命令行工作!耶!
然而,当我尝试
$ git difftool <commit>
Git 启动 kdiff3,然后我收到以下弹出错误:
Some input characters could not be converted to valid unicode.
You might be using the wrong codec. (e.g. UTF-8 for non UTF-8 files).
Don't save the result if unsure. Continue at your own risk.
Affected input files are in A, B.
...文件中的所有字符都是胡言乱语。命令行正确显示 diff 文本,但 kdiff3 由于某种原因无法正确显示 diff 中的文本。
如何在 kdiff3 或其他 GUI 工具中正确显示差异文本?我应该将 kdiff3 更改为其他工具吗?
Extra:由于这些命令,我的 shell 似乎无法找到 docx2txt:
$ which doctxt
which: no doctxt in (/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)
$ which docx2txt
/usr/bin/docx2txt