Max
Max

Reputation: 5932

Git Clone - Repository not found

git clone <url>

gives the message fatal: repository 'url' not found

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

Upvotes: 228

Views: 547392

Answers (30)

user2652315
user2652315

Reputation: 57

use personal access token to authenticate.

git clone https://@github.com/your-username/repository-name.git

Upvotes: -1

Ahmed Nabil
Ahmed Nabil

Reputation: 18966

In my case, I used 2 Github accounts.
And the git-credential tries to use the wrong password/token.

The solution # 1:

  • configure the git to use the full path for credential, by using the following command:
git config --global credential.usehttppath true

Then, You can see the update inside the global git config file ~./gitconfig.

[credential]
    usehttppath = true
  • Now, when you try git clone/fetch/..., the Username and Password will be asked for every repo.
  • Now, the right Password will be used

The solution # 2:

  • Make sure the git repo remote URL (inside repo/.git/config file) contains your Username. So instead of:
[remote "origin"]
        url = https://github.com/company-x/project-y.git

You can use the following form:

[remote "origin"]
        url = https://{Username}@github.com/company-x/project-y.git
  • Now, the right Password will be used

Upvotes: 9

Christian Fries
Christian Fries

Reputation: 16922

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/REPO_NAME/repo.git

try

git clone https://username:[email protected]/REPO_NAME/repo.git


You can also use

git clone https://[email protected]/REPO_NAME/repo.git

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

Upvotes: 525

Daniel Keele
Daniel Keele

Reputation: 57

Use the GitHub CLI. It has better error messages.

gh repo clone <org/repo>

Upvotes: 1

Seamus
Seamus

Reputation: 213

On the other hand, the problem may have nothing to do with passwords, private repos & all the other solutions offered in the other 30+ answers here:

  1. Go to the GitHub repo you want to clone

  2. 'Fork' the repo to your GitHub account

  3. Now, from your machine's CLI, do the "usual thing":

    $ git clone https://github.com/<your account>/<your fork> 
    

This is the exact procedure I followed when recently trying to clone some repos at the raspberry pi GitHub site... after spending a considerable amount of time reviewing other answers here.

Upvotes: 0

theking2
theking2

Reputation: 2793

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: "자격 증명 관리자"

Upvotes: 45

Ramesh
Ramesh

Reputation: 1763

I tried following and it worked on macOS

  1. Save the work and restart the system
  2. ssh-add ~/.ssh/id_rsa

Upvotes: 1

Gopala Raja Naika
Gopala Raja Naika

Reputation: 2669

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

Upvotes: 56

Andrew James Okpainmo
Andrew James Okpainmo

Reputation: 123

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

Upvotes: 0

Malakias
Malakias

Reputation: 1

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.

Upvotes: 0

Xahid
Xahid

Reputation: 99

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://[email protected]/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!

Upvotes: 9

phunder
phunder

Reputation: 1703

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.

Upvotes: 0

Viraj Singh
Viraj Singh

Reputation: 2319

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 [email protected] in the copied url

Step 4:

git remote add origin url

Upvotes: 4

Janaka Abeytunge
Janaka Abeytunge

Reputation: 51

git clone https://<USERNAME>@github.com/<REPONAME>/repo.git

This works fine. Password need to provide.

Upvotes: 4

de li
de li

Reputation: 922

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.

Upvotes: 6

quickshiftin
quickshiftin

Reputation: 69581

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.

Upvotes: 0

Roberto Escalon
Roberto Escalon

Reputation: 1

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.

Upvotes: 0

linktoahref
linktoahref

Reputation: 7972

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>

Upvotes: 2

uzair raza
uzair raza

Reputation: 38

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

Upvotes: -1

Robert P
Robert P

Reputation: 157

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

Upvotes: -4

kmario23
kmario23

Reputation: 61305

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://[email protected]/kmario23/repo-name.git

Upvotes: 5

Hieu Vo
Hieu Vo

Reputation: 3274

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.

Upvotes: 0

Brett Porter
Brett Porter

Reputation: 107

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 [email protected]:user/repo.git

Upvotes: 6

Victor Oliveira
Victor Oliveira

Reputation: 3713

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.

Upvotes: 20

Yura
Yura

Reputation: 3235

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.

Upvotes: 28

Andrew Watters
Andrew Watters

Reputation: 223

git clone https://[email protected]/User/Repository.git will prompt for a password then clone.

Upvotes: 12

Rajesh Ram
Rajesh Ram

Reputation: 11

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.

Upvotes: 1

user5196825
user5196825

Reputation:

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

Upvotes: 0

Amjad Khan
Amjad Khan

Reputation: 61

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.

Upvotes: 6

HumanCEO
HumanCEO

Reputation: 2561

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

Upvotes: 34

Related Questions