git compare for docx file

https://github.com/vigente/gerardus/wiki/Integrate-git-diffs-with-word-docx-files

This section was inspired by Martin Fenner's "Using Microsoft Word with git".

To configure git diff:

  1. Install pandoc.

  2. Tell git how to handle diffs of .docx files.

    1. Create or edit file ~/.gitconfig (linux, Mac) or "c:\Documents and Settings\user.gitconfig" (Windows) to add

       [diff "pandoc"]
         textconv=pandoc --to=markdown
         prompt = false
       [alias]
         wdiff = diff --word-diff=color --unified=1
      
    2. In your paper directory, create or edit file .gitattributes (linux, Windows and Mac) to add

       *.docx diff=pandoc
      
    3. You can commit .gitattributes so that it stays with your paper for use in other computers, but you'll need to edit ~/.gitconfig in every new computer you want to use.

Now you can see a pretty coloured diff with the changes you have made to your .docx file since the last commit

git wdiff file.docx

To see all changes over time

git log -p --word-diff=color file.docx

猜你喜欢

转载自my.oschina.net/u/2308739/blog/1802970