I put several .docx, .txt and .pdf file into a .git repository. I can open, edit, save the local .docx file; however, when I push it to github, and download it back to my computer, Word complains that it cannot open it. 
In order to store .docx file on github, is there some essential steps I should do to the git settings?
 
                        
Solution
Make a
.gitattributesfile in your working directory and add the following line to it:Why not just set
core.autocrlf=false?This is useful too. But configuring
.docxas a binary format solves not only this problem, but also potential merge issues.What is the origin of this problem?
From http://git-scm.com/docs/gitattributes , section "Marking files as binary". Note the italicized section.
.docxformat is a zip folder containtingxmland binary data, such as images.Git treated your
.docxas a text (and not binary) file and replaced endline characters. As Microsoft-developed format,.docxis probably using CRLF, which might have been replaced with LF in the remote repository. When you downloaded that file directly from remote, it still had LFs.In a binary file Git never replaces endline chars, so even the files on remote repository will have proper CRLFs.
Applicable formats
This is applicable to any file format which is a zipped package with text and binary data. This includes:
.odt,.ods,.odpand others..sxw,.sxc,.sxiand others..docx,.xlsx,.pptxand others.