2

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.

Filip Pranklin
  • 345
  • 1
  • 3
  • 14
  • Why do you need 2 GPG keys ? – Dinko Pehar Oct 04 '19 at 06:38
  • The generator asks for email, so I thought they were tied to the email address like SSH keys. I tried to add my existing GPG key to GitLab now and I get an error message saying that key has already been taken – Filip Pranklin Oct 04 '19 at 06:57

1 Answers1

1

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.

Dinko Pehar
  • 5,454
  • 4
  • 23
  • 57
  • I tried this exact steps yesterday and it didn't work, but it works now. Is there any chance it was related to me being connected to college WiFi which uses certificates tied to email address which I used for signing? – Filip Pranklin Oct 04 '19 at 07:30
  • I'm not sure. Maybe you didn't set properly local repository settings or you set GPG key you use on Github to be used for Gitlab. I'm not sure really... – Dinko Pehar Oct 04 '19 at 08:12