8

I am a collaborator in one the private github repository. I am able to fork it but when I try to clone it onto my system, it shows a pop up box asking for credentials and even if I enter correct credentials I can't login.

Is it just me or github actually doesn't allow cloning of private repo even if I am a collaborator in it?

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
Anjali
  • 143
  • 1
  • 1
  • 6
  • "it shows a pop up box asking for credentials" - this is not an adequate description of the popup window. What platform are you running on? Exactly what `git` software are you running? – Dai Sep 11 '21 at 05:02
  • @Dai I am using git bash – Anjali Sep 11 '21 at 05:05
  • What version of Git Bash? What credential cache provider or credential manager for git are you using? Are you using the GitHub-branded credential manager or the general-purpose manager? – Dai Sep 11 '21 at 05:06
  • @Dai I am using general purpose manager – Anjali Sep 11 '21 at 05:13
  • I have the same exact problem and if you found a solution please share – piterbarg Feb 21 '23 at 22:37

3 Answers3

5

You can clone it over HTTPS

git clone https://github.com/privateRepo/privateRepo.git

The prompt will ask for your username password/Authentication Token.

or

git clone https://username:token@github.com/user/repo

Note :- Support for password authentication was removed [link]. Please use a personal access token instead of password if it does not work.

1

I had the similar problem and realized that I am mistakenly adding an unnecessary <username> into the command.

Solution:

We should have or create personal access token. You can refer creating a personal access token link to create one. And the command should be:
git clone https://<personal_access_token>@github.com/<your account or organization>/<repo>.git

Be careful

I was mistakenly adding an extra <username> which is not seen in the repository link. We should simply use the repository link which already includes account user name or organization name.

For a repository link something like this https://github.com/mustafasdet/python.git, we should simply put personal_access_token after https://. And here is the command:

git clone https://ghb_qrghF29zGGmfd9w54hdf56vdnbWo90K82@github.com/mustafasdet/python.git

0

If you can fork it, you should be albe to clone it.

even if I enter correct credential

Make sure to use a PAT (Personal Access Token) as your password, instead of your actual GitHub account password.
This is because of "Token authentication requirements for Git operations" from Dec. 2020.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @ I have used personalized token already. But I am able to clone only public repo. Even if I am a collaborato in private repo I am not able to clone it – Anjali Sep 11 '21 at 05:05
  • @Anjali Is it a recent PAT, with the right scope? – VonC Sep 11 '21 at 05:05
  • @Anjali What is your git version, and the output of `git config --global credential.manager`? – VonC Sep 11 '21 at 05:14
  • my git version is 2.33.0.windows.2 and 'git config --global credential.manager' is not showing any output – Anjali Sep 11 '21 at 05:19
  • @Anjali For testing, can you try and create a new private repository (not a fork), and see of you can clone it (still using your PAT)? – VonC Sep 11 '21 at 05:24