如何使用多个帐户推送到gitlab?
我在如何使用多个帐户推送到gitlab?,git,push,gitlab,Git,Push,Gitlab,我在~/.ssh/config中设置如下: #Account one Host one.gitlab.com HostName gitlab.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa #Account two Host two.gitlab.com HostName gitlab.com PreferredAuthentications publickey
~/.ssh/config
中设置如下:
#Account one
Host one.gitlab.com
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
#Account two
Host two.gitlab.com
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_mastersystem
然后我试着像这样测试它:
这是成功
注:
姓名1=moses toh,用户名2=moschel(我大约2年前创建了这个帐户)
姓名2=moses,用户名2=moses639(我昨天做了这个账户)
然后我尝试推到gitlab
remote: Access denied
fatal: unable to access 'https://gitlab.com/xxxxx/myproject.git/': The requested URL returned error: 403
remote: Access denied
fatal: unable to access 'https://gitlab.com/xxxxx/myproject.git/': The requested URL returned error: 403
然后我再次尝试使用另一个帐户推送到gitlab
remote: Access denied
fatal: unable to access 'https://gitlab.com/xxxxx/myproject.git/': The requested URL returned error: 403
remote: Access denied
fatal: unable to access 'https://gitlab.com/xxxxx/myproject.git/': The requested URL returned error: 403
首先,你的测试是错误的。重点不是通过命令提供标识文件,而是通过主机名,所以请尝试
sshgit@one.gitlab.com
和sshgit@two.gitlab.com
你应该会收到不同的名字。快速浏览一下,您的SSH配置看起来不错
另一点是,你说“尝试推送”和“尝试与其他帐户推送”,但你没有这样做。如果您认为git remote添加了moses639https://gitlab.com/xxxxx/myproject将以用户身份推送moses639
这是完全错误的,因为这只是您配置的远程设备的本地名称,您可以将其命名为foo
,但仍然没有任何区别
此外,还可以使用
https
url。如果希望通过SSH配置文件选择标识,则这没有帮助。您必须通过SSH协议克隆(或实际推送),然后不使用gitlab.com
作为主机名,而是使用one.gitlab.com
或two.gitlab.com
,具体取决于您要使用的标识。实际上,您可以使用gitlab.com
和two.gitlab.com
,因为one.gitlab.com
无论如何都用默认键标识。首先,您的测试是错误的。重点不是通过命令提供标识文件,而是通过主机名,所以请尝试sshgit@one.gitlab.com
和sshgit@two.gitlab.com
你应该会收到不同的名字。快速浏览一下,您的SSH配置看起来不错
另一点是,你说“尝试推送”和“尝试与其他帐户推送”,但你没有这样做。如果您认为git remote添加了moses639https://gitlab.com/xxxxx/myproject将以用户身份推送moses639
这是完全错误的,因为这只是您配置的远程设备的本地名称,您可以将其命名为foo
,但仍然没有任何区别
此外,还可以使用
https
url。如果希望通过SSH配置文件选择标识,则这没有帮助。您必须通过SSH协议克隆(或实际推送),然后不使用gitlab.com
作为主机名,而是使用one.gitlab.com
或two.gitlab.com
,具体取决于您要使用的标识。实际上,您可以使用gitlab.com
和two.gitlab.com
,因为one.gitlab.com
仍然使用默认密钥进行标识。\Account one Host sshgit@one.gitlab.comHostName one.gitlab.com首选身份验证公钥标识文件~/.ssh/id_rsa#帐户二主机sshgit@two.gitlab.comHostName two.gitlab.com首选身份验证公钥IdentityFile~/.ssh/id_rsa_mastersystem
如果您的意思是要将配置设置为那样?你试着给出详细的答案,让我更容易理解不,我说配置看起来不错,但你不使用它。您可以添加一个以https://gitlab.com/
,而您应该使用SSH urlgit@one.gitlab.com:…
和git@two.gitlab.com:…
#帐户一台主机sshgit@one.gitlab.comHostName one.gitlab.com首选身份验证公钥标识文件~/.ssh/id_rsa#帐户二主机sshgit@two.gitlab.comHostName two.gitlab.comPreferredAuthentications公钥标识文件~/.ssh/id\u rsa\u mastersystem
如果您的意思是这样设置配置?你试着给出详细的答案,让我更容易理解不,我说配置看起来不错,但你不使用它。您可以添加一个以https://gitlab.com/
,而您应该使用SSH URLgit@one.gitlab.com:…
和git@two.gitlab.com:…
。