Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Clone error: Could not switch to

Tags:

git

github

centos

Im getting a Fatal Error when trying to clone a repo to a new directory. I can't see what I'm doing wrong.

Im on a CentOS server, at the command line running:

git clone [email protected]:MYUSERNAME/REPONAME.git newdirectory

I get the error:

fatal: Could not switch to '[email protected]/MYUSERNAME': No such file or directory

newdirectory definitely exists, and the user I am logged in as has write permissions, and also has a github ssh key set up.

If i put something in the newdirectory

Anyone got any ideas I can try? Cheers


UPDATE: This is what happens if I try SSL based instead of 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

I think this is to be expected though, its a private github repo, Im not sure https works for private repos? Part of why I have always used ssh (successfully) in the past.

like image 704
Rob Avatar asked Jan 27 '26 15:01

Rob


1 Answers

Well, I seem to have fixed it. I'm not sure why I haven't needed it before and do now, but adding ssh:// seems to have solved my problem:

git clone ssh://[email protected]:MYUSERNAME/REPONAME.git newdirectory

Is that ssh:// prefix normally required?

thanks to @WoLpH for getting me to play with the urls!

like image 163
Rob Avatar answered Jan 30 '26 07:01

Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!