black sensei
black sensei

Reputation: 6678

Switching git global config between gitlab and github

Where I work we have a hosted gitlab which requires a clietn ssl certificate to allow connection. That has been configured in git global config so my ~/.gitconfig and it works well. The client certificate request is only at the reverse proxy level. We still use username/password as credentials though.

[http]
   sslCert = /Users/xuser/gitlab_ssl/xxx.crt
   sslKey = /Users/xuser/gitlab_ssl/xxx.key

Now each time I need to clone from github, I get could not load PEM client certificate, LibreSSL error error:02001002:system library:fopen:No such file or directory, (no key found, wrong pass phrase, or wrong file format?)

I tried using override the configuration with -c git -c http.sslCert="" -c http.sslKey="" clone https://github.com/xxxxx but it doesn't work. I tried using aliases but I have not seen anything that is using aliases on top level config like the [http] block in git.

Is there a way to have: 1 - "git clone bla bla" which uses company gitlab 2 - "git everythingelse clone bla bla" which doesn't try to load the client certificate?

Thanks in advance.

Upvotes: 0

Views: 381

Answers (1)

Dietrich Epp
Dietrich Epp

Reputation: 213338

Change your configuration from

[http]

To

[http "https://gitlab.com"]

This will make those configuration settings only apply to URLs that point at GitLab. Other URLs like GitHub will be unaffected by the configuration changes in this block. If you access your hosted GitLab through a different URL, simply put that URL in the configuration.

Upvotes: 2

Related Questions