Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Tobiaqs
Last active January 15, 2020 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tobiaqs/7c715b7085fece7d5a5ad54c615e79e2 to your computer and use it in GitHub Desktop.
Save Tobiaqs/7c715b7085fece7d5a5ad54c615e79e2 to your computer and use it in GitHub Desktop.
Using Github/Bitbucket as an encrypted file backup service

Initial setup

This will get you a repository that automatically encrypts all files that you add to it and push.

  1. Get git and git-crypt and gpg
  2. Make sure you have a trusted private key in gpg
  3. Run git-crypt init in the root of your repo
  4. Run git-crypt add-gpg-user GPG_FINGERPRINT
  5. Create .gitattributes in the root of your repo
**/* filter=git-crypt diff=git-crypt
.gitattributes !filter !diff
*.gitignore !filter !diff
  1. Add .gitattributes to your repo
  2. Commit

Now any file that you add to the repo and push will be encrypted online

Restoring repo

  1. Get git and git-crypt and gpg
  2. Make sure you have a trusted private key in gpg that was also added to the repository using git-crypt add-gpg-user
  3. Clone your encrypted repo
  4. Run git-crypt unlock in the root of your repo

Sync without keeping history

Your repository can become huge after some commits, so (in this rare case) it's better to delete your previous commit, create a new one and force push.

git reset --soft HEAD^
git-crypt unlock
git add .
git commit -m stuff
git push -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment