Git
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Store credentials
In order to setup git to store your credentials you need to execute this:
Commit Signing
Signing your commits gives you the ability to prove that you were the author of a specific code change. It also gives you the ability to ensure that no one can modify your commit (or its metadata, such as the time you claimed that was made at) in the future.
Setup GPG
Install GPG:
- Windows: Download the Gpg4win distribution from the GPG website
- macOS:
brew install gpg
- Linux: Most Linux distributions come with GPG pre-installed; if not, you can always find it on their official repositories.
Disable password request (macOS and Linux):
Enable gpg in every terminal session:
Generate GPG key pair
Generate a new GPG pair:
- Kind of key:
type 4 for (4) RSA (sign only)
- Keysize:
4096
- Expiration: choose a reasonable value, for example
2y
for 2 years (it can be renewed) - Enter your real name
- Enter the email address you use in git (
git config --global user.email
). You can add more emails after the setup.
Adding multple emails
Edit your generated key:
Configure Git to sign your commits
Setup git to use GPG:
Setup git to use your key:
Setup git to sign all commits:
Adding the GPG key to GitHub
In order for GitHub to accept your GPG key and show your commits as “verified”, you first need to ensure that the email address you use when committing a code change is both included in the GPG key and verified on GitHub.
Copy the whole output including the -----BEGIN PGP PUBLIC KEY BLOCK-----
and -----END PGP PUBLIC KEY BLOCK-----
and go to the GitHub SSH and GPG Settings and put it in there.