200
git clone <url>

gives the message fatal: repository 'url' not found

I tried the options in the link, but it didn't work.

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
Max
  • 5,380
  • 6
  • 42
  • 66
  • surely your url must be invalid.. – g-newa Sep 20 '14 at 08:58
  • 2
    is it a private repo or a public one? - If it is, try and use the HTTPS address instead of the GIT one. (I hope that you are not doing what @JohnZwinck said...) – appostolis Sep 20 '14 at 08:59
  • If the repo is public, could you edit your question to add the corresponding url? – jub0bs Sep 20 '14 at 16:58
  • Hi Jubos, its a private repo and i do have the access to that repo. – Max Sep 21 '14 at 07:35
  • 36
    I faced a similar situation. The URL I used for my private repository was correct. But I was getting the same error. After much digging I found that in the keychain (I am using Mac Yosemite), entry for the github.com had the old password for github. I deleted the entry from the keychain then I ran the git clone command. It asked my github username/password and wallah the clone worked! – Shirish Kumar Mar 13 '15 at 05:06
  • Also make sure that your token has correct scopes - https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps – bitsabhi Sep 13 '21 at 08:22
  • The URL should end with a ".git" – Big Al Jan 18 '22 at 20:33

32 Answers32

480

As mentioned by others the error may occur if the url is wrong.

However, the error may also occur if the repo is a private repo and you do not have access or wrong credentials.

Instead of

git clone https://github.com/NAME/repo.git

try

git clone https://username:password@github.com/NAME/repo.git


You can also use

git clone https://username@github.com/NAME/repo.git

and git will prompt for the password (thanks to leanne for providing this hint in the comments).

Christian Fries
  • 16,175
  • 10
  • 56
  • 67
  • 4
    Thanks - that was useful. I've run into this problem on only one of my systems but can't figure out why. Using the 2nd method works, but I am curious why and if I need to keep using this? What would be cause the problem with the first command, but not with the second? – Levon Feb 17 '16 at 22:53
  • 4
    On Mac OS X you can store username and password in Keychain (e.g. for GitHub). Then you do not need the second command. If you do not have any thing like this, you need the second command. – Christian Fries Jul 30 '16 at 22:11
  • I don't know y. I have been facing the same problem and second solution works – Rameshwar Jun 08 '17 at 13:57
  • Also, Adding SSH key in your git account's setting will solve the problem – Rameshwar Jun 08 '17 at 14:07
  • what if the password has @ in there? – Deepak Kumar Jul 15 '17 at 18:01
  • Is there any variant of the username:password@github.com syntax for private repos that doesn't require entering the password visibly in the CLI? One would think git would prompt for auth in this case... maybe I'm running into the OSX keychain cached creds problem – CCJ Sep 12 '17 at 21:37
  • 9
    @CCJ, yes: you can enter everything in the command *except* the `:password`, and git will prompt for the password. For example: `git clone https://username@github.com/NAME/repo.git` – leanne Oct 10 '17 at 17:35
  • 1
    @ChristianFries it would be awesome if you could update your answer to include the non password visible option in Leanne's comment for future readers. – John Pavek Nov 22 '17 at 18:08
  • 1
    @JohnPavek: Done. – Christian Fries Nov 27 '17 at 09:40
  • 5
    Also, if you have 2-Factor authentication enabled you should use an access token instead of the password - see: https://stackoverflow.com/questions/21892226/can-i-use-githubs-2-factor-authentication-with-tortoisegit – Pawel Gorczynski May 08 '18 at 14:51
  • In my case, url to private repo was correct but this suggestion helped me, I was able to clone using git clone https://username:password@github.com/NAME/repo.git – pixel Jan 11 '19 at 17:38
  • removing ssh key from github, did the job :) – justnajm Jul 09 '20 at 18:43
  • Thanks for this answer. After hours of searching I finally found something that worked for me. – VIVEK JAIN Aug 04 '21 at 10:21
  • 1
    No longer working: `Support for password authentication was removed on August 13, 2021` – Kutalia Aug 02 '22 at 13:23
  • 1
    git clone "https://username@github.com/NAME/repo.git" work for me, however password authentication was removed, we need to personal token, -> Setting ->Developer setting -> Personal access tokens -> token classic . Next work for me , if you use SSO and 2-Factor authentication enabled, also you can configure in the same token. – Henry Xiloj Herrera Jan 04 '23 at 17:50
50

On macOS it's possible that the cached credentials in the Keychain that git is retrieving are wrong. It can be an outdated password or that it used the wrong credentials.

To update the credentials stored in OS X Keychain

Follow the instructions at:

https://help.github.com/articles/updating-credentials-from-the-osx-keychain/

If you want to verify this is the problem you can run clone with tracing.

$ GIT_CURL_VERBOSE=1 git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY

Look for the header line "Authorization: Basic BASE64STRING" .
Take the base64 string and decode it to check what username:password was used.

$ echo <the key> | base64 --decode

Verify it's the right username password you expected to use.

tsafrir
  • 1,711
  • 12
  • 13
  • I try this and it gives me the username/password for my _other_ account. I guess I need to specify user name... – Nicolas Miari May 19 '17 at 07:30
  • 2
    This GIT_CURL_VERBOSE=1 is insanely helpful - thanks! – mistertee May 15 '18 at 12:25
  • If you find your username/password is not correct, how to make git use another one? – toancaro Jun 09 '20 at 17:39
  • 1
    macos keychain can store multiple github logins. If you want to specify which one, `username@` to the github url. Example: `https://username@github.com/foo/bar.git` Then macos keychain will use the correct login password. – wisbucky Nov 12 '20 at 20:11
42

If your git repo is private, try this

git clone https://<USERNAME>:<PASSWORD>@github.com/<USERNAME>/<REPO_NAME>.git

Note: If you are using @ symbol in your password, use '%40' to instead '@'

else use this

git clone https://github.com/<USERNAME>/<REPO_NAME>.git

----Update:----

Using a password in clone URL is now deprecated instead use the personal access token like below

Setting -> Developer Settings -> personal access tokens -> generate new token

git clone https://<Token>@github.com/<USERNAME>/<REPO_NAME>.git
Gopala Raja Naika
  • 2,321
  • 23
  • 18
38

If you are on Windows, the repository is private, and different or not longer correct credentials were saved once, you won't have access to the repo. You will get the not found error without hinting in the failed-credential-direction. In order to reset the credentials on Windows, open Control Panel (Win+r control), select User Accounts and Credentials Manager or search for "credential manager" in Start Menu. Locate the git account in Windows credentials (not Web credentials!) and erase this entry.

After that, cloning will pop up a login dialogue and you will be able to set these again.

Tested this with git-bash as shell

In other languages

In Start menu search for

  • En: "Credential Manager"
  • NL: "Referentiebeheer "
  • DE: "Anmelde Informationsverwaltung"
  • KR: "자격 증명 관리자"
theking2
  • 2,174
  • 1
  • 27
  • 36
32

If you are using two factor authorization (2FA) for your Github account then just use SSH option for cloning your repository:

enter image description here

Olegdater
  • 2,381
  • 22
  • 20
27

I had the same problem (Repository not found) due to the fact that initially I logged in with an incorrect GitHub account. To fix it:

  1. Open Control Panel from the Start menu.
  2. Select User Accounts.
  3. Select "Manage your credentials" in the left hand menu.
  4. Delete any credentials related to Git or GitHub.
pmichna
  • 4,800
  • 13
  • 53
  • 90
Yura
  • 2,925
  • 2
  • 18
  • 27
  • 1
    This solved the problem for me. I have multiple github accounts, so in Windows, sometimes the git credentials are cached for the other account inside of the windows credentials manager. Clearing away the cached account allows for this issue to be resolved. – Grizzly Peak Software Dec 26 '18 at 18:57
  • This incorrect account (cached one) may have not permission to view the repository, so Github/Gitlab return a 404 Not Found error. – mrdaliri Jan 29 '19 at 07:21
  • 404 instead of UnAuthorized error. This error message is misleading. Thanks for your help. It works for me too :) – Diallo May 22 '20 at 13:15
26

Most probably, your URL is not valid.

If it is a http/https URL, you can quickly check, by hammering the URL into a browser. If that does not display anything at all, you know that the URL is invalid.

I assume you are speaking of a remote repository. The URLs should look somewhat like these:

https://github.com/user/repo2.git if you're using HTTPS
git@github.com:user/repo2.git if you're using SSH
Kai Mattern
  • 3,090
  • 2
  • 34
  • 37
25

I was also having same issue. I was trying to clone the repo which was private and my git installed in osx has keychain which was not allowing me to clone the repo...

I tried

git clone https://username:password@github.com/NAME/repo.git 

but it didn't work as my password was containing the field @.

I just ran

git credential-osxkeychain erase
host=github.com
protocol=https

command and press enter and it worked perfectly fine. Actually you need to remove the keychain already stored in the osx.

Vikas Chandra
  • 565
  • 1
  • 9
  • 22
25

For me

git clone https://username@github.com/name/repo.git

worked.

I think this mainly happens because Private repo can't be accessed directly.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Manish Menaria
  • 23,899
  • 3
  • 21
  • 23
  • Unfortunately, this solution no longer works...here's the message I got when I tried it: `Support for password authentication was removed on August 13, 2021.` – RSW Oct 12 '22 at 16:10
19

What solved my problem, since I was having a "redirect/sign_in URL" or "repository not found" error

MacOS Users:

  1. Open spotlight (Command Space)
  2. Type keychain (Open keychain access.app)
  3. Search for repo domain (GitHub, GitLab, etc)
  4. Delete all keys related to this domain
  5. Try to clone again (with valid credentials)

Windows users should try similar steps, but Keychain would be Microsoft's Credentials Manager instead or Windows Credentials depending on yours OS version. Make sure to clean both web and windows credentials if that's the case.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Victor Oliveira
  • 3,293
  • 7
  • 47
  • 77
  • This may have fixed my issue, not entirely sure since it didn't seem to have an effect at first but later without doing other changes it all started to work again. – patrick.elmquist Jun 08 '18 at 12:46
  • if you have two or more keys chain containing name gitlab and you are not able to delete all in one go then try to delete one by one.(delete one at a time and close keychain section and repeat for the next one) – Jitendra Aug 12 '18 at 18:06
  • Using MacOS Big Sur, deleting the github entry on Key Chain solved the issue. – yaach Jul 27 '21 at 13:55
12

git clone https://username@github.com/User/Repository.git will prompt for a password then clone.

Andrew Watters
  • 223
  • 4
  • 9
  • This solution no longer works...here's the message I got when I tried it: `Support for password authentication was removed on August 13, 2021.` – RSW Oct 12 '22 at 16:09
10

On github you can have the main repository and subfolders. Make sure that the URL that you are using is that of the main repository and not that of a folder. The former will succeed and the latter will produce the repository not found error. If you have a doubt you are in a subfolder, navigate up the repository chain till you find a page which actually specified the https URL and use that.

Nikhil George
  • 471
  • 7
  • 9
  • 1
    This was my problem. If you've got the right level then you should see the `Clone or Download` button on the github page for the URL. If it's not there, then you can't clone it. – Stephen Hosking Apr 08 '18 at 02:57
9

Step 1: From your Github account, go to Settings Account Settings
Then, Developer Settings Developer Settings
Then Personal Access Token PAT Settings
Then, Generate New Token (Give your password) Generate Token

Now Fillup the form (scope/access permission of the repository) and click Generate token and Copy the generated Token (Copy and save it, it will be shown for the first time only, otherwise you have to generate it again), it will be something like ghp_sFhFsSHhTzMDreGRLjmks4TzuzgthdvfsrtaCopy Token

Step 2: Now, copy the resource indicator:Resource Indicator

For example: https://github.com/AnwarXahid/sso-client-java-servlet.git and it is generated by https://github.com/**YOUR USERNAME**/YOUR REPO NAME.git

Finally, open terminal/ git bash and add the PAT token before resource indication:
For example: https://ghp_sFhFsSHhTzMDreGRLjmks4Tzuzgthdvfsrta@github.com/AnwarXahid/sso-client-java-servlet.git
Basically, it is generated by https://YOUR TOKEN@github.com/YOUR USERNAME/YOUR REPO NAME.git

So, the final command would like this: git clone https://YOUR TOKEN@github.com/YOUR USERNAME/YOUR REPO NAME.git

Press ENTER and your repo will be cloned to local!

Community
  • 1
  • 1
Xahid
  • 99
  • 1
  • 6
  • It would be helpful to explain to which situations your answer applies. E.g. what you described won't help if the URL is simply wrong. – Jan Wilamowski Aug 23 '21 at 07:07
  • @JanWilamowski When a Personal Access Token(PAT) is generated, by default GitHub assumes that the token will simply be used for the public repository (As no access option is chosen by default). In this case, if you use this token for cloning a private repository, you must get an error. My solution specifically works for this type of situation. – Xahid Aug 23 '21 at 09:10
  • 2
    this is an excellent explanation for when trying to access private repos thank you – d0rf47 Dec 17 '21 at 16:48
6

This is happening because of my old session state of other user remain: Below is quick solution for Windows users,

Open Control Panel from the Start menu Select User Accounts Select "Manage your credentials" in the left hand menu Delete any credentials related to Git or GitHub

Once I did this, it started working for me.

Amjad Khan
  • 61
  • 1
  • 3
6

For me the problems occurs because I have my old username/password settings saved for gitlab, so that I need to remove those credentials. I run the following command on my mac:

sudo su
git config --system --unset credential.helper

and do the clone again, enter the username and password. And everything is fine.

de li
  • 882
  • 1
  • 13
  • 25
5

This issue started surfacing on my terminal after I enabled GitHub 2FA.

Now, I face this issue whenever I clone a private repository. This error:

remote: Repository not found.
fatal: repository 'https://github.com/kmario23/repo-name.git/' not found

is so awkward. Of course, I have this repo and I'm the owner of it.

Anyway, it seems the fix is now that we have to enter the GitHub username one more time when cloning a private repo. Below is an example:

                             add your username
                                |-------|
$ git clone --recursive https://kmario23@github.com/kmario23/repo-name.git
kmario23
  • 57,311
  • 13
  • 161
  • 150
4

enter image description here

Step 1: Copy the link from the HTTPS

Step 2: in the local repository do

git remote rm origin

Step 3: replace github.com with username.password@github.com in the copied url

Step 4:

git remote add origin url
Viraj Singh
  • 1,951
  • 1
  • 17
  • 27
3
git clone https://<USERNAME>@github.com/<REPONAME>/repo.git

This works fine. Password need to provide.

  • Never add passwords to git clone command especially if you are using this in a CI / CD pipeline. Always use a ssh authentication and add the SSH key in your git hub account settings. Adding passwords as plain text is highly insecure. – Max Jan 29 '21 at 10:25
2

For me it worked by removing the credential.helper config and cloning the repository again

git config --global --unset credential.helper
git clone https://<repository>
linktoahref
  • 7,812
  • 3
  • 29
  • 51
1

You may need to create an empty file named git-daemon-export-ok within the repository directory.

mono blaine
  • 1,001
  • 9
  • 13
1

Authentication issue: I use TortoiseGit GUI tool, I need to tell tortoise the username and password so that it can access to work with Git/GitHub/Gitlab code base. To tell it, rt click inside any folder to get TortoiseGit menu. Here TortoseGit > Settings Window > Select Credentials in left nav tree Enter URL:Git url Helper: Select windows if your windows credentials are same as the ones for Git or 'manager' if they are different userName; Git User Name Save this settings ans try again. You will be prompted for password and then it worked.

Rajesh Ram
  • 11
  • 2
1

I'm a devops engineer and this happens with private repositories. Since I manage multiple Github organizations, I have a few different SSH keys. To overcome this ERROR: Repository not found. fatal: Could not read from remote repository. error, you can use

export GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o User=git -i ~/.ssh/ssh_key_for_repo"

git clone git@github.com:user/repo.git
0

If you are using cygwin for git and trying to clone a git repository from a network drive you need to add the cygdrive path.

For example if you are cloning a git repo from z:/

$ git clone /cygdrive/z/[repo].git

0

Possibly you did login in another account, and that account doesn't have access rights to this repo, if you're using mac os, go to Keychain Access, search for gitlab.com and remove it and try to git clone again.

Hieu Vo
  • 3,105
  • 30
  • 31
0

You should check if you have any other github account marked as "default". When trying to clone a new repo, the client (in my case BitBucket) will try to get the credentials that you have set "as default". Just mark your new credentials "as default" and it will allow you to clone the repo, it worked for me.

0

Another reason for this error, if you are on github, and trying to use deploy keys for multiple repos, you will find this does not work.

In that case you need to create a machine user, however if you don't and you try to clone any repo besides the one with the deploy key, you will get this error.

quickshiftin
  • 66,362
  • 10
  • 68
  • 89
0

I had this issue recently and after quite a bit of debugging I realized that the password that I got from a password generator had an "&" in it, which GitHub accepted, but Visual Studio Code did not like when I tried to clone the reopo. Not sure which system threw the error, but it made me realize that stage characters in your user name or password could also cause this issue.

phunder
  • 1,607
  • 3
  • 17
  • 33
0

I had this same problem in Windows, when I tried to use Git on the command line in Git Bash terminal while having also GitHub desktop installed. So, I did not have any problem using desktop app, but trying to clone in Git Bash failed. There are lots of advice for deleting any previous Git and GitHub related credentials, but this would then mess up GitHub desktop so it is not a good solution if you want to use both GUI and command line methods. Surprisingly, when I just used Windows command prompt interface (Git CMD) instead of Git Bash, it started working. So, it seems Git Bash has problems co-operating with GitHub desktop configurations, but Windows command prompt works ok.

0

I faced the same error today(25/12/2021). The repo was a private repo. I simply installed and configured Github CLI on my machine(running ubuntu 20.04 OS). And it cloned just fine. I push with HTTPS. Here are some links that will be very helpful:

  1. https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git
  2. https://github.com/cli/cli#installation
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/30670823) – knittl Dec 25 '21 at 19:23
0

I tried following and it worked on macOS

  1. Save the work and restart the system
  2. ssh-add ~/.ssh/id_rsa
Ramesh
  • 1,703
  • 18
  • 13
-1

In my case. repository is private I can't access it directly. On ly way to use Github Desktop app to fetch this repo.

uzair raza
  • 23
  • 1
  • 8
-4

open Credential Manager -> look for your GIT devops profile -> click on it -> edit -> add user and password generated in DevOps and save.

Robert P
  • 137
  • 2
  • 10