In the end of your original .gitconfig
add includeIf
with the directory where your .gitconfig-B will be applied:
# ref https://dzone.com/articles/how-to-use-gitconfigs-includeif
# when gitdir matchs, then use .gitconfig-B
[includeIf "gitdir:~/src/github.com/myprojects/"]
path = ~/.gitconfig-B
# ref https://dzone.com/articles/how-to-use-gitconfigs-includeif
#.gitconfig-B content:
[commit]
gpgsign = true
[gpg]
program = gpg
[user]
name = <github username here>
email = email@email.com
signingkey = <your GPG sign key here>
If you get the following error when commit
error: gpg failed to sign the data
fatal: failed to write commit object
Kill gpg-agent and set GPG_TTY
kill -9 $(pgrep gpg-agent)
export GPG_TTY=$(tty)
Then try to commit and push and verify
git log --show-signature -1
commit 06854fae3c93ec1ed63152c6d1176433294d9692 (HEAD -> master, origin/master, origin/HEAD)
gpg: Signature made Wed Mar 25 11:22:04 2020 -03
gpg: using RSA key 56DA862EA1F1E684753F3504CAD550B16B996590
gpg: Good signature from "Alex Lopes (GPG for Personal Use) <lopes.alex.antonio@gmail.com>" [ultimate]
Author: alexlopes <lopes.alex.antonio@gmail.com>
Date: Wed Mar 25 11:22:04 2020 -0300