One can use MD5 or plain text diff to see differences in PDF files. If that's not enough, here's how to use diffpdf which knows how to diff based on appearance or words.
apt-get install diffpdf
- edit your
~/.gitconfig
to add this:
[difftool "diffpdf"]
cmd = diffpdf \"$LOCAL\" \"$REMOTE\"
- then use with:
git difftool --tool=diffpdf your_pdf_file.pdf
- to always use that diff methods for pdf put the wollowing in your
.gitattributes
:
*.pdf difftool=diffpdf
For command line use there ist pdftotext
, which renders the PDF as plain text. The following instructions are from [https://tante.cc/2009/03/24/versioning-pdf-files-with-git/]
- git needs the contents to diff on stdout. You have to write a short wrapper for pdftotext. Call it “pdf2txt”, put it in /usr/local/bin or if you have it in ~/bin. It contains:
#!/bin/bash
pdftotext $1 -
- add the following to your
~/.gitconfig
[diff "pdf"]
textconv = pdf2txt
- In your repository edit the file
.gitattributes
and add the line
*.pdf diff=pdf
Git tricks for programming and tex