【问题标题】:Unable to push files to second github repo from same machine无法从同一台机器将文件推送到第二个 github 存储库
【发布时间】:2019-07-21 08:12:30
【问题描述】:

我有两个 github 帐户,他们的用户名是这样的:

subhayan-bhattacharya
subhayan-test

现在我想使用同一台机器在两个存储库中进行工作(推/拉)。因此我为此设置了两个 ssh 密钥。默认指向 subhayan-bhattacharya 帐户。

total 48
drwx------   8 subhayan.bhattachary  1796758494   256 Jul 20 23:46 .
drwxr-xr-x+ 38 subhayan.bhattachary  1796758494  1216 Jul 20 23:46 ..
-rw-r--r--   1 subhayan.bhattachary  1796758494    50 Jul 20 23:31 config
-rw-------   1 subhayan.bhattachary  1796758494  3401 Jun 14 15:28 id_rsa
-rw-r--r--   1 subhayan.bhattachary  1796758494   755 Jun 14 15:28 id_rsa.pub
-rw-r--r--   1 subhayan.bhattachary  1796758494   990 Jul  5 13:36 known_hosts
-rw-------   1 subhayan.bhattachary  1796758494  1856 Jul 20 23:41 newkeys
-rw-r--r--   1 subhayan.bhattachary  1796758494   421 Jul 20 23:41 newkeys.pub

我已将相关的 ssh 密钥添加到各个 git hub 帐户的 ssh 和 gpg 密钥部分。

我的 .ssh/config 文件如下所示:

7tvmb228:.ssh subhayan.bhattachary$ vi config

Host *
   AddKeysToAgent yes
   UseKeychain yes

问题是我无法推送到 subhayan-test 帐户。我试过这样:

7tvmb228:starter-web subhayan.bhattachary$ ssh-add ~/.ssh/newkeys
Identity added: /Users/subhayan.bhattachary/.ssh/newkeys (subhayan.bhattachary@7tvmb228.fritz.box)
7tvmb228:starter-web subhayan.bhattachary$ git push
ERROR: Permission to subhayan-test/starter-web.git denied to subhayan-bhattacharya.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

~

我不知道为什么它说 subhayan-bhattacharya 的权限被拒绝,因为这是另一个 git hub 帐户名称。

但是,对其他帐户的推送和拉取工作正常。

我应该检查什么以及为什么这似乎不起作用。

【问题讨论】:

标签: git ssh ssh-keys


【解决方案1】:

对于第二个帐户,您的配置应包括:

Host bhat
  Hostname github.com
  User git
  IdentityFile /.ssh/newkeys

然后在您的存储库中:

cd /path/to/repo
git remote add bhat bhat:subhayan.bhattachary/starterweb.git
git push bhat master

如果您需要推送到 subhayan-test/starter-web.git,请确保(独立于任何 SSH 密钥)推送到 add subhayan.bhattachary as a collaborator

【讨论】:

  • 让我试试这个,然后告诉你。非常感谢您的回答。
猜你喜欢
  • 2011-11-24
  • 2016-03-20
  • 2021-11-27
  • 1970-01-01
  • 2021-09-28
  • 2012-08-25
  • 2011-12-09
  • 2019-06-18
  • 2015-08-04
相关资源
最近更新 更多