在Mac OS X上使用Git对带有docx2txt的Word .docx文件进行版本控制 [英] Version control Word .docx files with docx2txt with Git on Mac OS X

查看:200
本文介绍了在Mac OS X上使用Git对带有docx2txt的Word .docx文件进行版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

On Git web site there is a detailed instruction for version controling Microsoft Word .doc files with catdoc.

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

但是,我意识到这不适用于.docx文件.似乎您需要docx2txtunoconv而不是catdoc(

However, I realized that this doesn't work for .docx files. It seems that you need either docx2txt or unoconv instead of catdoc (found here). I decided to go with docx2txt for no reason, but I was stuck at the installation of docx2txt into Mac OS X.

此类说明了这些步骤.据我了解,您所需要的只是在合理的地方docx2txt.pl.我以为/usr/local/bin/可以.我在那儿复制了它.然后,根据说明,我尝试了以下操作:

This sort of illustrates the steps. In my understanding, all you need is docx2txt.pl at somewhere sensible. I thought /usr/local/bin/ would do. I copied it there. Then, according to the instruction, I tried the following:

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

当我尝试此操作时:

$ docx2txt

我知道了

Can't read docx file <>!

因此,docx2txt似乎在路径中.

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

Then I edited .gitattributes in the repository folder (ASCII, LF) to add the following line:

*.docx diff=wordx

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

Then, I also edited .git/config file in the repository as follows:

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

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

Because the repository is already in use, I didn't do git init. I edited a .docx Word file in the repository and then typed git diff in the Terminal. But result was not successful.

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

有人可以提出任何建议吗?

Could anyone have any suggestions?

推荐答案

感谢巴生,我成功了.现在,我可以在Mac OS X(10.9)的Terminal.app中比较.docx文件.但是,此代码无法与SourceTree GUI无缝协作.以下与巴生的基本相同,但有一些较小的更正.

Thanks to klang, I made it. Now I can diff .docx files in Terminal.app in Mac OS X (10.9). But this one doesn't seamlessly work with SourceTree GUI. Below is basically the same as klang's but with minor corrections.

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

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

Then make a small wrapper script to make docx2txt output to 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.

Use .git/info/attributes if the setting should not be committed with the project.

(Word).doc差异的Git属性

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

这篇关于在Mac OS X上使用Git对带有docx2txt的Word .docx文件进行版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆