# How to git diff for MS-Excel files(xls/xlsx) on Mac-OS ## Installation ### Prerequisites * Requires Java 1.6 or higher. * Assumes Java is added to PATH (to check open a cmd and run java -version) * No other platform specific requirements * A shell script and a bat script are packaged Just [download](https://github.com/na-ka-na/ExcelCompare/releases) the zip file. Extract it anywhere (and optionally you add the bin folder to PATH). #### macOS [Homebrew](http://brew.sh/) makes it easy to install ExcelCompare: $ brew update $ brew install excel-compare ## All what you have yo do 1. Create **exceldiff.cmd** command file anywhere with write permission and add the following to it:
_\/bin/excel_cmp $2 $5_
e.g. _/usr/local/Cellar/excel-compare/0.6.1/bin/excel_cmp $2 $5_ Why arguments **two** and **five**? It’s because Git passes seven arguments to a diff command, of which the second is the path to the old file (which likely is a temporary file) and the fifth is the path to the new file. For more detailed information, have a look at the [Git documentation](https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes), specifically under GIT_EXTERNAL_DIFF. 2. Edit the **.git/config** file in your repository and amend the following path:
_[diff "excel"]
command = \_
e.g. _[diff "excel"]
command = /usr/local/Cellar/excel-compare/0.6.1/bin/exceldiff.cmd_ 3. Next, we must tell Git to associate certain files with the excel diff driver. To do so, edit **.gitattributes** in the root of your repository and amend the following:
_*.xlsx diff=excel_
_*.xls diff=excel_ **Note:** * Git attributes are set either in a **.gitattributes** file in one of your directories (normally the root of your project) or in the .**git/info/attributes** file if you don’t want the attributes file committed with your project. * **.gitattributes** (unlike **.gitignore**) must be committed to have any effect, so add it to a commit at this point. ## Usage * Compare with HEAD revision
**_git diff \_** * Compare file between 2 commits
**_git diff \ \ \_**