gpt4 book ai didi

git - 无法使用第二个个人 github 帐户进行 Git 克隆

转载 作者:行者123 更新时间:2023-12-05 05:48:00 24 4
gpt4 key购买 nike

除了第一个 github 帐户外,我还在我的笔记本电脑上添加了第二个 github 帐户。文档https://betterprogramming.pub/how-to-use-multiple-github-accounts-with-one-computer-c9ba3f851b75确实有很大帮助,但我在克隆可从第二个 github 帐户访问的存储库时遇到问题。

我生成了 key id_rsa_unaccountid_rsa_unaccount.pub 并将 id_rsa_unaccount.pub 的内容添加到第二个 github 帐户中的 ssh 字段.

>ls ~/.ssh  
config id_rsa id_rsa.pub id_rsa_unaccount id_rsa_unaccount.pub

更新了 ~/.ssh/config

# Account 1 (work or personal) - the default config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa

# Account 2 (personal) - the config we are adding
Host github-unaccount
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_unaccount

同时设置

git config user.name "Gupastha" 
git config user.email "asthagupta92+8@gmail.com"

但是,当我尝试 git clone 存储库时,我看到了

git clone git@github-unaccount:Noble-Missions/itakeactions.git 
Cloning into 'itakeactions'...
ERROR: Repository not found.
fatal: Could not read from remote repository.

我也经历了相同的多个堆栈溢出链接,但我找不到克隆的解决方案。任何人都可以轻推我吗?

最佳答案

首先检查您的第二个 key 是否被识别:

ssh -Tv github-unaccount

不需要 git@ 因为它包含在你的 ~/.ssh/config

然后使用,假设类Linux环境:

export GIT_SSH_COMMAND='ssh -v'
git clone github-unaccount:Noble-Missions/itakeactions.git

您将看到在克隆操作期间考虑了哪些键。

OP Astha Gupta确认使用了错误的 key ,因为来自 the comments :

I had an additional entry in the ssh config: Host *, which was pointing to id_rsa.

关于git - 无法使用第二个个人 github 帐户进行 Git 克隆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70898935/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com