在 gitlab 和 github 之间切换 git 全局配置 [英] Switching git global config between gitlab and github

查看:87
本文介绍了在 gitlab 和 github 之间切换 git 全局配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的地方有一个托管的 gitlab,它需要 clietn ssl 证书才能允许连接.这已经在 git global config 中配置,所以我的 ~/.gitconfig 并且它运行良好.客户端证书请求仅在反向代理级别.不过,我们仍然使用用户名/密码作为凭据.

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

现在每次我需要从 github 克隆时,我都会得到 无法加载 PEM 客户端证书,LibreSSL 错误错误:02001002:system library:fopen:No such file or directory,(找不到密钥,密码错误,还是错误的文件格式?)

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?)

我尝试使用 -c git -c http.sslCert="" -c http.sslKey="" clone https://github.com/xxxxx 覆盖配置,但它没有工作.我尝试使用别名,但我没有看到任何在顶级配置中使用别名的东西,比如 git 中的 [http] 块.

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.

有没有办法:1 - 使用公司 gitlab 的git clone bla bla"2 - 不尝试加载客户端证书的git everythingelse clone bla bla"?

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?

提前致谢.

推荐答案

更改您的配置

[http]

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

这将使这些配置设置仅适用于指向 GitLab 的 URL.GitHub 等其他 URL 将不受此块中配置更改的影响.如果您通过不同的 URL 访问托管的 GitLab,只需将该 URL 放在配置中.

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.

这篇关于在 gitlab 和 github 之间切换 git 全局配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆