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 protected]
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 objectKill 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) <[email protected]>" [ultimate]
Author: alexlopes <[email protected]>
Date: Wed Mar 25 11:22:04 2020 -0300