- Download and install the GPG command line tools for your operating system. We generally recommend installing the latest version for your operating system.
- Open Git Bash.
- Generate a GPG key pair. If you are not on version 2.1.17 or greater then
gpg --default-new-key-algo rsa4096 --gen-key
- Enter your user ID information.
- Type a secure passphrase. This is a must.
- list the long form of the GPG keys
gpg --list-secret-keys --keyid-format=long
- From the list of GPG keys, copy the long form of the GPG key ID you'd like to use. In this example, the GPG key ID is
6516ETRY5D63A374
gpg --list-secret-keys --keyid-format=long
sec rsa4096/6516ETRY5D63A374 2022-04-20 [SC] [expires: 2024-04-19]
728B31B9A433BF3KOY549042651642177D63A374
uid [ultimate] username <[email protected]>
- Paste the text below, substituting in the GPG key ID you'd like to use. In this example, the GPG key ID is
6516ETRY5D63A374
gpg --armor --export 6516ETRY5D63A374
- Copy your GPG key, beginning with -----BEGIN PGP PUBLIC KEY BLOCK----- and ending with -----END PGP PUBLIC KEY BLOCK-----.
- Adding a new GPG key to GitHub
gpg --list-secret-keys --keyid-format=long
The below mentioned key id is dummy for understanding purposes.
sec rsa4096/6516ETRY5D63A374 2022-04-20 [SC] [expires: 2024-04-19]
728B31B9A433BF3KOY549042651642177D63A374
uid [ultimate] username <[email protected]>
Here only copy 6516ETRY5D63A374
- cd ~/to_the_repository_directory
git config user.signingKey <copied key id in earlier step>
git config user.email <your email id>
git config --global user.signingKey 651642177D63A374
git config --global user.email [email protected]