2017-05-17 102 views
2

我遇到了一个奇怪的问题,同时使用SSH克隆git仓库。我有SSH设置:Github SSH工作,但使用SSH克隆失败

ssh -T [email protected] 
Hi yusufali2205! You've successfully authenticated, but GitHub does not provide shell access. 

我使用正确的克隆网址,并有机会获得我想克隆回购。但得到错误:

➤ git clone [email protected]:<some-org>/<repo>.git 
Cloning into 'project'... 
Permission denied (publickey). 
fatal: Could not read from remote repository. 

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

没有其他消息来调试我的SSH设置或git配置有什么问题。

回答

3

我发现在我的.gitconfig中有一个条目用https代替ssh。

[url "https"] 
    insteadOf = git 

我可能在使用某种工具时意外添加了这个条目。所以克隆命令实际上是使用url [email protected]:<some-org>/<repo>.git

.gitconfig删除上述条目后,问题已解决。