Browse the .docx file on Github and use git diff in .docx format.

I have two questions:

  • Is there a way to view the .docx file on Github ? We have downloaded all of our assignments on Github, but we cannot view it in a browser. It would be nice if we could view these .docx files in a browser without downloading the file.

  • How can I use git diff in .docx file format? I tried to use catdoc , but for me it did not work. I think I used to use git diff on Windows for the .doc format, but it does not work for me on a Mac.

Thank you very much.

+6
source share
5 answers
  1. Answer the second part of the question. Already an old post, but appears in the top 10 without an answer. With the following settings, you get a bad interface for docx files.

In .gitattributes use:

 *.docx diff=zip 

In .git / config use:

 [diff "zip"] textconv = unzip -c -a 

As a bonus, my settings for the old word / excel and the new word / excel:

In .gitattributes use:

 *.doc diff=word *.xsl diff=excel *.xlsx diff=zip *.docx diff=zip 

In .git / config use:

 [diff "word"] textconv = strings [diff "excel"] textconv = strings [diff "zip"] textconv = unzip -c -a 
+5
source

Answering your second question -

Usually when trying

 git diff filename.docx 

you will get the result of the form -

The binaries a / filename.docx and b / filename.docx are different

Not very helpful. The perfect way to use Pandoc .

  • Install Pandoc on top of the link to your system.
  • Create or edit the file ~ / .gitconfig (linux, Mac) or "c: \ Documents and Settings \ user.gitconfig" (Windows) to add (or use git config --global --edit )

     [diff "pandoc"] textconv=pandoc --to=markdown prompt = false [alias] wdiff = diff --word-diff=color --unified=1` 
  • In your git managed directory with .docx files, create or edit a .gitattributes file (linux, Windows and Mac) to add

     *.docx diff=pandoc 
  • You can commit .gitattributes so that it remains for use on other computers, but you will need to edit ~ / .gitconfig on every new computer that you want to use.

  • Now you can see a rather colorful diff with the changes you have made to your .docx file since the last commit

      git wdiff file.docx 

More information can be found here .

+2
source

Is there a way to view the .docx file in Github?

Not yet (Q4 2016) if the Word document is not clear text.

How can I use git diff in .docx format?

Since git for Windows 1.9.5 and Git for Windows 2.5.3 (September 2015 and question 355 ), you do not need to make any user settings:

 git diff -- myWord.docx 

It will work. (This is also an ode for .doc and .pdf too)

And since Git is for Windows 2.10.1 , you can also distinguish between docm and dotm (see PR 128 ).

+1
source

This is problematic and as far as I know impossible on github or any other git host. While git can be used for versioning, things like git diff will return differences between the two versions in text form. Illegible.

I feel that this is not without reason. There are unlimited file formats in the world, and many of them are property. Thus, instead of supporting each format, such as VLC, git uses text files for everything.

In addition, even if git somehow supports docx, it will not be able to display formatting changes inside the terminal, not to mention cmd. If this is just text, it is best to save it as a text file. Or manually check the previous version to compare the changes.

0
source

The .docx file is actually a zip (you can change the file type and pop it inside). If .docx was considered as a directory, then inside the main IS file it is stored as an XML style file and is not binary text.

The sad thing is that there is no curry return. Otherwise, making diff text in the document.xml file inside the directory would be really helpful. Since the line of the file, the XML file in the file will not affect the contents so that they can be added.

0
source

All Articles