Skip to content

Instantly share code, notes, and snippets.

@turboBasic
Last active October 31, 2024 15:14
Show Gist options
  • Save turboBasic/29d00adf652aa0a8a582478c95cd566a to your computer and use it in GitHub Desktop.
Save turboBasic/29d00adf652aa0a8a582478c95cd566a to your computer and use it in GitHub Desktop.
Use git-crypt & symmetric key kept inside a repo to encrypt some files in the repository

Use symmetric key to encrypt repository

Encrypt using symmetric key and keep the key in the repository

  1. cd repo; git-crypt init

  2. Add files which need to be encrypted to .gitattributes

echo "secretfile1.txt  filter=git-crypt diff=git-crypt" >> .gitattributes
echo "secretfile2.txt  filter=git-crypt diff=git-crypt" >> .gitattributes
  1. Add local.key to .gitignore
echo local.key >> .gitignore
  1. Commit .gitattributes and .gitignore
git add .gitattributes .gitignore
git commit -m "Config: git-crypt settings"
  1. Encrypt repo using git-crypt & encrypt they key using GPG and your password
git-crypt init
git-crypt export-key local.key
gpg --symmetric --armor local.key
rm local.key
git add local.key.asc
git commit -m "Config: add symmetric encryption key"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment