Github克隆错误: Could not switch to

标签 git github centos

我在尝试将存储库克隆到新目录时遇到 fatal error 。我看不出我做错了什么。

我在 CentOS 服务器上,在命令行运行:

git clone git@github.com:MYUSERNAME/REPONAME.git newdirectory

我得到错误:

fatal: Could not switch to 'git@github.com/MYUSERNAME': No such file or directory

newdirectory 确实存在,并且我登录的用户具有写入权限,并且还设置了 github ssh key 。

如果我在新目录中放一些东西

任何人有任何想法我可以尝试吗?干杯


更新: 如果我尝试基于 SSL 而不是 SSH,就会发生这种情况:

-bash-4.1$ git clone https://github.com/MYUSERNAME/REPONAME.git newdirectory Initialized empty Git repository in /var/www/html/newdirectory/.git/ error: The requested URL returned error: 401 while accessing >https://github.com/MYUSERNAME/REPONAME.git/info/refs

fatal: HTTP request failed

不过我认为这是可以预料的,它是一个私有(private)的 github 存储库,我不确定 https 是否适用于私有(private)存储库?我过去一直(成功)使用 ssh 的部分原因。

最佳答案

好吧,我好像已经修好了。 我不确定为什么我以前不需要它现在不需要它,但是添加 ssh://似乎已经解决了我的问题:

git clone ssh://git@github.com:MYUSERNAME/REPONAME.git newdirectory

通常需要 ssh://前缀吗?

感谢@WoLpH 让我玩转 url!

关于Github克隆错误: Could not switch to,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17344677/

相关文章:

git - 移除了 Remote 。但远程分支仍然显示

xcode - 用下载的最新 1.8.3 替换 Xcode 的 git

git - 使用所有分支更新 fork 的 Github 存储库

github - 如何克隆 GitHub wiki?

推送时出现Git错误(远程无法报告状态)

c++ - 如何为 CentOS 6.10 编译 node.js(库问题)

node.js - 将我的 node.js 应用程序从 Github 部署到 VPS

docker - 如何将 rpm 安装到/usr/bin 而不是/opt/app-root/bin

installation - Prestashop 1.7.7.5 安装问题 : ps_facebook1

GIT,不要 merge 特定文件