de en

Thorsten Reimers

Git geänderte Excel Dateien

21.06.2024

Um Excel Dateien in den Git Diff aufzunehmen und mehr als "binary files" differ zu erhalten, kann Excel Compare verwendet werden.

$ brew update $ brew install excel-compare

Create exceldiff.cmd command file anywhere with write permission and add the following to it:
<path-to-the-excel-compare-installation-folder>/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, specifically under GIT_EXTERNAL_DIFF.

Edit the .git/config file in your repository and amend the following path:
[diff "excel"]
command = <path-of-the-command-file-above>
e.g.
[diff "excel"]
command = /usr/local/Cellar/excel-compare/0.6.1/bin/exceldiff.cmd

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

Hier die Anleitung für macOS: Es wird Ghostscript mit Homebrew installiert, danach kann man es verwenden.

$ brew install gs
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf *.pdf

Quellen:

https://gist.github.com/PrabhatKJena/0884644ae01a49a9819aebd883e54003

https://stackoverflow.com/questions/28026767/where-should-i-place-my-global-gitattributes-file