How to use Git in a secure way

Do not commit sensitive information

bfg --delete-files id_{dsa,rsa} my-repo.git

Protect the access to your Git repositories

Sign your work

  • Don’t use short-length keys. Today, 4096-bit keys are recommended.
  • When creating a new key pair, don’t forget to generate a revocation key and store it in a safe place.
  • Protect your private key with a passphrase.
  • Avoid using an infinite validity period for your keys. It would become a time bomb if one day you lose a key, especially if you can’t revoke it for any reason.

Keep Git and related tools up to date



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store