Is it possible to have git encrypt and decrypt a file during a push/pull?
git encrypt/decrypt remote repository files while push/pull
I’d like to store some private data in a git repository that is going out in the world, basically some private configuration, and so on. I’d like to (somehow) have the file encrypted either as I commit it, or as I push it (preferably the latter, because then I can do reasonable diffs against the text form), and also obviously the inverse.
Is this possible with git’s hooks?
One Solution collect form web for “Is it possible to have git encrypt and decrypt a file during a push/pull?”
One way of doing this is is to encrypt the objects as they’re being staged, and decrypted on checkout. This is rather earlier than doing it solely on
pull, but might be useful to you.
The way to do this is to use git’s “smudge” and “clean” filters, but it’s not necessarily recommended for reasons that are explained here by Junio C Hamano, the maintainer of git:
If you still decide to go ahead, you may want to look at this implementation of encrypting/decrypting clean/smudge filters: