2
votes

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.

2
The https authentication works, if no authentication is given it should ask you for authentication when needed. The 401 would indicate that the user you are using to authenticate with has no access to the repository anymore. If this is not the case than I would suspect that there might be a problem on github's end. - Wolph

2 Answers

3
votes

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!

2
votes

I believe you forgot to authenticate with Github. Do you have a private key on that machine which has access to that Github repository?

To make sure the rest works, try a https checkout instead. If that works than you know it's the authentication you have to worry about.