Encrypted git diff

There’s a pattern that I sometimes use, to store encrypted text files in git.
That doesn’t mean that you need to lose git’s power behind the encryption.

Sample Repository

Teach git how to decrypt a file before diffing.

# .git/config
...
[diff "gpg"]
binary = true
textconv = gpg2 -d --quiet --yes --compress-algo=none --no-encrypt-to --batch --use-agent

Tell git to use the gpg method to diff encrypted files.

# .gitattributes
*.gpg diff=gpg