Created
January 18, 2023 14:29
-
-
Save ad2ien/790fed69bd79f5753032eb676d27f55d to your computer and use it in GitHub Desktop.
configure git and github to sign commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
set -euo pipefail | |
# Interactively generate a new GPG key | |
gpg --default-new-key-algo rsa4096 --gen-key | |
# Get key id | |
KEY=$(gpg --list-secret-keys --keyid-format=long \ | |
| grep '^sec.*$' \ | |
| tr -s ' ' \ | |
| cut -d ' ' -f 2 \ | |
| cut -d '/' -f 2) | |
# Configure git client | |
git config --global user.signingkey $KEY | |
git config --global commit.gpgsign true | |
echo "Your public key (to give to github) :" | |
echo "" | |
gpg --armor --export $KEY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment