Skip to content

Instantly share code, notes, and snippets.

Last active April 25, 2023 16:53
What would you like to do?
How to show diffs for gpg-encrypted files?
*.gpg filter=gpg diff=gpg
*.asc filter=gpg diff=gpg

How to show diffs for gpg-encrypted files?

Git supports showing diffs for encrypted files, but has to be told to do so.

git config --global diff.gpg.textconv "gpg --no-tty --decrypt"
echo "*.gpg filter=gpg diff=gpg" >> .gitattributes
echo "*.asc filter=gpg diff=gpg" >> .gitattributes


curl -sL -o .gitattributes
Copy link

anastygnome commented Apr 13, 2021

One may also find the following useful :
git config diff.gpg.textconv "gpg2 --decrypt -q"

Copy link

pass uses textconf = gpg2 -d --quiet --yes --compress-algo=none --no-encrypt-to --batch --use-agent when configured as git repo

Copy link

If you want to actually see the diff of the GPG messages that normally go to STDERR you have to use a subshell like this:
textconv = sh -c 'gpg --no-tty --decrypt $0 2>&1'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment