Skip to content

Instantly share code, notes, and snippets.

Diffing PDFs for git

Visual difftool

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\"
# Produce PDFs from all Markdown files in a directory
# Lincoln Mullen | http://lincolnmullen.com | [email protected]
# List files to be made by finding all *.md files and appending .pdf
PDFS := $(patsubst %.md,%.md.pdf,$(wildcard *.md))
# The all rule makes all the PDF files listed
all : $(PDFS)
# This generic rule accepts PDF targets with corresponding Markdown
function gitInfo=getGitInfo()
% Matlab script to get information about the Git repository in the current directory, including:
% - branch name of the current Git Repo
% -Git SHA1 HASH of the most recent commit
% -url of corresponding remote repository, if one exists
%
% The function first checks to see if a .git/ directory is present. If so it
% reads the .git/HEAD file to identify the branch name and then it looks up
% the corresponding commit.
%