我一直在尝试获取在 Windows 7 上的 Sourcetree 中工作的 Word .docx 文件的文本差异。我已按照此处的说明进行操作将 Microsoft Word 与 git 结合使用 http://blog.martinfenner.org/2014/08/25/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 http://freemind.s57.xrea.com/xdocdiffPlugin/en/,您可以按照建议安装或放入您喜欢的文件夹中;
-
在 Windows 中添加文件夹PATH
变量,如上所述here https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them(需要重启才能生效);
-
通过在命令行窗口中键入命令来验证一切正常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 内的差异预览。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)