Skip to content

Instantly share code, notes, and snippets.

@marceloalmeida
Last active December 7, 2023 14:26
Show Gist options
  • Save marceloalmeida/e6593b93b388cdf1dbc282dffd424d1b to your computer and use it in GitHub Desktop.
Save marceloalmeida/e6593b93b388cdf1dbc282dffd424d1b to your computer and use it in GitHub Desktop.
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

or

curl -sL https://gist.github.com/marcelosousaalmeida/e6593b93b388cdf1dbc282dffd424d1b/raw/.gitattributes -o .gitattributes
@nikonoid
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