If you don't have a GPG signing key yet, generate a new GPG key using one of the resources below:
- https://docs.github.com/en/github/authenticating-to-github/generating-a-new-gpg-key
- https://docs.gitlab.com/ee/user/project/repository/gpg_signed_commits/index.html
Creat agpg
alias below,
alias agpg="GPG_EMAIL=$(git config user.email) && GPG_KEY=$(gpg --list-secret-keys --keyid-format LONG $GPG_EMAIL | awk '/sec/{print $2}' | cut -d'/' -f 2) && git config user.signingkey $GPG_KEY && git config commit.gpgsign true && printf '%s has been added to the repository associated with %s' $GPG_KEY $GPG_EMAIL"
Then, go into a repository where you want to activate GPG signing and run agpg
command.
➜ cd my-awesome-repository
➜ agpg
3AA5C34371567BD2 has been added to the repository associated with [email protected]
The alias lookups existing GPG keys in your machine and add the key associated with the email configured in the repository to Git.