我一直在尝试获取在 Windows 7 上的 Sourcetree 中工作的 Word .docx 文件的文本差异。我已按照此处的说明进行操作 Using Microsoft Word with git使用 Pandoc 并可以从命令行让它工作。不幸的是,我无法让那个差异出现在 Sourcetree 中。我还需要做些什么才能让它发挥作用吗?
这是我放在项目根目录中的 .gitattributes 文件:
# Add diff of docx files.
*.docx diff=word
这是我的 .git\config 文件:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[diff "word"]
textconv=pandoc --to=markdown
prompt = false
[alias]
wdiff = diff --word-diff=color --unified=1
最佳答案
我正在寻找相同问题的解决方案。 Pandoc 似乎不能很好地与 SourceTree 配合使用,我想知道是否有有效的替代方案。然后我想起 WinMerge 在几年前使用外部工具 xdocdiff 解决了这个问题。步骤:
如果您还没有,请下载 xdocdiff here ,可以按照提示安装,也可以放在自己喜欢的文件夹中;
在 Windows
PATH
变量中添加文件夹,如所述 here (需要重启才能生效);通过在命令行窗口中键入命令
xdoc2txt
验证一切正常,输出将是用法帮助程序(如下所示):> xdoc2txt Usage: xdoc2txt [-s|-e|-j][-c][-f][-r=(0|1|2)] <filename...> -s : convert to ShiftJIS(default) -e : convert to EUC -j : convert to JIS -f : output to file -c : activate PDF cache -p : print property -n : ignore permission on PDF;(require cryptlib.dll) -r=(0|1|2) : ruby style(0:suppress 1:parentheses 2:aozora bunko -o=0 : other option; -o=0:no show PDF page# -g=# : PDF gap parameter -v : show version number -x : output existing cell only(for EXCEL2007)
仅当此命令有效时才继续;
在项目根目录下添加或编辑
.gitattributes
文件:*.doc diff=xdoc2txt *.xls diff=xdoc2txt *.docx diff=xdoc2txt *.xlsx diff=xdoc2txt # ... # add any other supported extensions you need
编辑项目根目录下的
.git\config
文件:[diff "xdoc2txt"] textconv = xdoc2txt cachetextconv = true binary = true prompt = false
这些行允许我在 SourceTree 中查看差异预览。
关于windows - Windows 7 上 Sourcetree 中的 Diff Word docx 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32734617/