gpt4 book ai didi

macos - 在 Mac OS X 上使用 Git 对带有 docx2txt 的 Word .docx 文件进行版本控制

转载 作者:太空狗 更新时间:2023-10-29 14:07:52 26 4
gpt4 key购买 nike

Git 网站上有一个详细的说明,用于使用 catdoc 控制 Microsoft Word .doc 文件的版本。

http://git-scm.com/book/en/Customizing-Git-Git-Attributes

但是,我意识到这不适用于 .docx 文件。看来您需要 docx2txtunoconv 而不是 catdoc ( found here )。我决定无缘无故地使用 docx2txt,但我被困在将 docx2txt 安装到 Mac OS X 中。

This有点说明了这些步骤。据我了解,您所需要的只是位于合理位置的 docx2txt.pl。我认为 /usr/local/bin/ 可以。我在那里复制了它。然后,根据the instruction ,我尝试了以下方法:

$ cd /usr/local/bin/
$ echo '#!/bin/bash
docx2txt.pl "$1" -' > docx2txt

当我尝试这样做时:

$ docx2txt

我得到了

Can't read docx file <>!

所以,docx2txt 似乎在路径中。

然后我在存储库文件夹(ASCII,LF)中编辑 .gitattributes 以添加以下行:

*.docx diff=wordx

然后,我还编辑了存储库中的 .git/config 文件,如下所示:

[diff "wordx"]
binary = true
textconv = docx2txt

因为存储库已经在使用中,所以我没有执行git init。我在存储库中编辑了一个 .docx Word 文件,然后在终端中输入 git diff。但是结果没有成功。

Binary files a/foo/foo.docx and b/foo/foo.docx differ

谁能有什么建议?

最佳答案

感谢 klang,我做到了。现在我可以在 Mac OS X (10.9) 的 Terminal.app 中区分 .docx 文件。但是这个不能与 SourceTree GUI 无缝协作。以下与 klang 的基本相同,但有一些小的更正。

http://docx2txt.sourceforge.net/ 下载并安装docx2txt 转换器

wget -O doc2txt.tar.gz http://docx2txt.cvs.sourceforge.net/viewvc/docx2txt/?view=tar
tar zxf doc2txt.tar.gz
cd docx2txt/docx2txt/
sudo make

然后制作一个小的包装脚本来将 docx2txt 输出到 STDOUT

echo '#!/bin/bash
docx2txt.pl "$1" -' > /usr/local/bin/docx2txt
chmod +x /usr/local/bin/docx2txt

存储库中 (Word).docx 差异的 Git 属性

echo "*.docx diff=wordx" >> .gitattributes
git config diff.wordx.textconv docx2txt

如果设置不应与项目一起提交,请使用 .git/info/attributes

(Word) .doc 比较的 Git 属性

echo "*.doc diff=word" >> .gitattributes
git config diff.word.textconv strings

关于macos - 在 Mac OS X 上使用 Git 对带有 docx2txt 的 Word .docx 文件进行版本控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22190208/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com