【问题标题】:Diff Word docx files in Sourcetree on Windows 7Windows 7 上 Sourcetree 中的 Diff Word docx 文件
【发布时间】:2015-09-23 08:32:18
【问题描述】:

我一直在尝试获取在 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

【问题讨论】:

标签: windows git diff docx atlassian-sourcetree


【解决方案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
    # ...
    # add any other supported extensions you need
    
  • 编辑项目根目录下的.git\config文件:

    [diff "xdoc2txt"]
      textconv = xdoc2txt
      cachetextconv = true
      binary = true
      prompt = false
    

这些行让我可以看到 SourceTree 中的差异预览。

【讨论】:

  • 我很高兴我不是唯一一个尝试这样做的人。但是,我已尝试按照您的指示进行操作,但仍然无法正常工作。您使用的是哪个版本的 SourceTree?我有版本 1.6.22.0。
  • 我的是 1.6.20.0。确保打开 Windows 的命令行,如果您键入命令 xdoc2txt,它不会返回 command not found 错误。
  • 您是否获得了舞台或放弃了大块命令来工作?显示差异适用于当前版本 2.4.7.0,但每当我尝试丢弃一个大块时,我都会收到一个错误:'git apply' failed with code 1: [...] error: while searching [...]。好吧,我想从 sourcetree 回到相应的帅哥的路上可能仍然缺少一些东西?
  • 您如何使用 mercurial?
【解决方案2】:

在设置 SourceTree > 工具 > 选项 > Git > 使用系统 Git 后,它适用于 pandoc 或 xdoc2txt !

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-07
    • 1970-01-01
    • 1970-01-01
    • 2014-11-25
    • 2018-09-18
    • 1970-01-01
    • 2013-05-09
    • 1970-01-01
    相关资源
    最近更新 更多