Skip to content

Instantly share code, notes, and snippets.

@billykong
Last active September 1, 2021 13:30
Show Gist options
  • Save billykong/622f06f9917fb1df78b1a47ccb5b2e6a to your computer and use it in GitHub Desktop.
Save billykong/622f06f9917fb1df78b1a47ccb5b2e6a to your computer and use it in GitHub Desktop.

Question:

Why is git-crypt not encrypting my files?

Answer

We must git-crypt unlock the repository first for git-crypt to encrypt the file for us upon commit.

A pre-commit hook to avoid accidental commit of sensitive data:

#!/bin/sh
#pre-commit
git-crypt status | grep "WARNING"; test $? -eq 1 # edited

Credit: https://www.gitmemory.com/issue/AGWA/git-crypt/45/614607121

Note that the pre-commit hook file must be set to executable, e.g. chmod 744 .git/hooks/pre-commit

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