Old-school cloning over HTTPS of private repo

Hi. I have not had to do this for some time, but the need has arisen. I need to clone a (new) private repo using just HTTPS: . When I do this, I get an error message that I’ve not seen before:

$ git clone https://hangarr09@github.com/hangarr/SoundPipeC.git
Cloning into 'SoundPipeC'...
Password for 'https://hangarr09@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://hangarr09@github.com/hangarr/SoundPipeC.git/'

This is on a Mac running El Capitan with git from Xcode for El Capitan. Just for completeness, I also seem to get anomalous results when I do this (note it doesn’t as for credentials):

$ git clone https://github.com/hangarr/SoundPipeC.git
Cloning into 'SoundPipeC'...
remote: Repository not found.
fatal: repository 'https://github.com/hangarr/SoundPipeC.git/' not found

$ git clone https://hangarr@github.com/hangarr/SoundPipeC.git
Cloning into 'SoundPipeC'...
remote: Repository not found.
fatal: repository 'https://hangarr@github.com/hangarr/SoundPipeC.git/' not found

and:

$ git clone https://hangarr09:xxxxxxxx@github.com/hangarr/SoundPipeC.git
Cloning into 'SoundPipeC'...
remote: Invalid username or password.
fatal: Authentication failed for 'https://hangarr09:xxxxxxxx@github.com/hangarr/SoundPipeC.git/'

(Obviously I’ve masked the password.)

Any ideas what’s going wrong here? I can’t use SSH on this machine for non-technical reasons and I don’t have 2FA enabled as far as I can see. Thanks very much for any help.

The documentation on Cloning with HTTPS URLs has been stating this for a while:

Password-based authentication for Git is deprecated, and we recommend using a personal access token (PAT) when prompted for a password instead, which is more secure. Treat your token just like a password. For more information, see “Creating a personal access token.”

Does it work if you use a PAT instead of your password?

Thanks.

Unfortunately, that seems to have uncovered a second issue. Note the error message here:

$ git clone https://hangarr09@github.com/hangarr/SoundPipeC.git
Cloning into 'SoundPipeC'...
Password for 'https://hangarr09@github.com':   *(PAT entered here)*
remote: Repository not found.
fatal: repository 'https://hangarr09@github.com/hangarr/SoundPipeC.git/' not found

Here’s the message with an invalid PAT:

$ git clone https://hangarr09@github.com/hangarr/SoundPipeC.git
Cloning into 'SoundPipeC'...
Password for 'https://hangarr09@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://hangarr09@github.com/hangarr/SoundPipeC.git/'

And just for completeness again:

Wellspri2:Project 1 hangartner$ git clone https://hangarr09:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@github.com/hangarr/SoundPipeC.git
Cloning into 'SoundPipeC'...
remote: Repository not found.
fatal: repository 'https://hangarr09:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@github.com/hangarr/SoundPipeC.git/' not found

Wellspri2:Project 1 hangartner$ git clone https://github.com/hangarr/SoundPipeC.git
Cloning into 'SoundPipeC'...
remote: Repository not found.
fatal: repository 'https://github.com/hangarr/SoundPipeC.git/' not found

Is GitHub possibly allowing me to create a private repo but not clone it? This is a personal (free) account being used here to share an example of some old work with another single entity. To my recollection, in the old days GitHub didn’t allow one to create a private repo on a free account.

Thanks for any insights.

Hm, the only reason I can think of would be that the PAT lacks the repo scope. Without that you can only read public data. You can check and if necessary update that on the same settings page where you can generate new tokens.

I remember that was the case, but that’s changed, see GitHub Free for user accounts.

Thanks for your assistance. What you’ve suggested makes perfect sense but it appears there may be some other problem with GitHub and private repos. Although I’m sure I gave the first PAT repo scope, just to confirm I created a second with (only) repo scope and got the same failure:

Perhaps this needs to be brought to the attention of some team at GitHub? Any ideas how to do that? Thanks again for your assistance.

I just noticed one more thing: The user account you’re using for authentication and the one owning the repository aren’t the same. Does the former actually have access to the private repository?

There are some Github people on this forum, I would hope one of them sees this. I’ve moved this thread to the #how-to-use-git-and-github section to hopefully make that easier. :wink:

Or you could try the contact form: https://support.github.com/request

Thanks very much for the additional thoughts.

You caught something that also has been an unanswered question for me. This repo was created sometime ago with the user name “hangarr” that corresponds to an email account “hangarr@yyyyy.com” on a domain yyyyy.com I own. I made that email account the secondary email account on this GitHub account. I added a public account hangarr09 account as the primary email account. I can log in with both email addresses for some reason. That has turned out to be convenient if puzzling.

Just to be safe, I tried adding both accounts as collaborators on the repo and this went through without a hiccup by Github but without any notification to either email account. I can’t seem to find a list of collaborators on this repo but I probably don’t know where to look these days.

I get the same error message trying both with one difference:

$ git clone https://hangarr09@github.com/hangarr/SoundPipeC.git
Cloning into 'SoundPipeC'...
Password for 'https://hangarr09@github.com': 
remote: Repository not found.
fatal: repository 'https://hangarr09@github.com/hangarr/SoundPipeC.git/' not found

$ git clone https://hangarr@github.com/hangarr/SoundPipeC.git
Cloning into 'SoundPipeC'...
remote: Repository not found.
fatal: repository 'https://hangarr@github.com/hangarr/SoundPipeC.git/' not found

Notice the first asks for a password and the second gives up (immediately). I’m assuming the first at least is getting through authentication and the second is saying that the actual repo “username” is not a valid for cloning the private repo.

Thanks also for explaining how GitHub folks monitor the communities and for moving this to the correct section. I appreciate your efforts on this.

I don’t think “hangarr09” is an actual GitHub usename as it is not found when searched for on GitHub.
A user “hangarr” is found.
Your write up is a little confusing, but perhaps you have two emails registered on single github account username “hangarr09”.
So firstly the clone must use an actual GitHub username.

Cloning a private repository using a correctly scoped PAT definitely works when the user have read access to the repository if the repository is owned by th user doing the clone you definetly have pwrmiasions. Easily checked by using the the gui and and accessing the repository, you can also copy the clone URL format
So setting up a correctly scoped Pat on this user and uisbg it for the clone should work.

Thanks very much for your response and the additional info.

You’re correct there is a primary and secondary email associated with this Github account. I can login on the website with the username or either email account name. While that is a good thing, it turns out it confused me.

Your clarification that I can only clone with the username was the key. When I used the username with a PAT it worked.

Thanks both of you for your help.

1 Like

@hangarr, glad you are working now, you can mark the answer as a solution if this is now solved