gitgithubgitlabgpg-signature

Handling GPG keys with separate emails for GitLab and GitHub


How does one handle GPG key(s?) with two different email addresses, one on GitHub and the other on GitLab.

I have a college email address and they force me to use GitLab.

I have a private email address which I use for GitHub.

I want those two completely separated, but there are some issues.

I already have separate SSH keys and that works fine, but when I try to utilize two GPG keys, I get GPG signing error unless I set gpgsign = false in global .gitconfig, but nothing gets signed then.


Solution

  • Git has configuration both for Global and Local.

    Global means settings for every repository on your computer. Local means settings for a single repository.

    To set global configuration for signingkey use:

    git config --global user.signingkey <gpg-key-id>
    

    To set for local, switch to repository you want to change configs for and use:

    git config user.signingkey <gpg-key-id>
    

    When you execute git config user.signingkey you should see proper configuration.