GitHub is a web-based service that allows software developers to store and manage their code. However, when some users tried cloning their code in GitHub, the service couldn’t find the repository. In this post, we will address this issue and see what you need to do if the Remote repository is not found when cloning in GitHub.
Why isn’t my Git clone working?
Git clone will not work if it doesn’t have the required permission. However, one of the things you can do is give the account permission in the URL itself. So, instead of git clone URL, git clone https://username:password@URL or git clone https://username@URL. If this doesn’t work, check out the solutions mentioned below.
Fix Remote Repository not found when cloning in GitHub
If the remote repository was not found when cloning in GitHub, follow the solutions mentioned below.
- Make sure that the URL is not wrong
- Set up Git authentication when cloning a private repository
- Remove and then add the credentials
Let’s get started.
1] Make sure that the URL is not wrong
If you are cloning the GitHub repository and have entered the wrong URL then your service will not able to able to find the repository. To correct this issue, all you have to do is enter the correct URL. For that, go to the GitHub page of the repository where we were going to make the clone and hit the Code button. Then, in the Local tab, click on the Clipboard option placed next to the HTTPS field. To clone the GitHub repository, type the following command and press the Enter button.
git clone [URL of repository]
Once the operation is completed, you will check your repository by typing the ls command.
2] Set up Git authentication when cloning a private repository
If your URL is correct but you are unable to clone the repository then check if you are cloning a private repository. If you are cloning a private repository, follow the steps mentioned below to set up your Git authentication. To set up Git authentication, we must set a username and email with the Git configuration command.
- Enter the following command to set your username
git config --global user.name "FIRST_NAME LAST_NAME"
- Next, you should configure the email by entering the following command
git config --global user.email "[email protected]"
Now, a valid Personal Access token is required for your GitHub account that has read access to a particular repository that you are trying to clone. If you don’t have a personal access token, you must create it. For that, follow the steps given below.
- Log in to your GitHub account.
- Hit the Profile icon and select Settings.
- Scroll down the screen and then click on Developer Settings.
- On the top left corner of the screen, click on the “Personal access tokens” option. You will get two choices here first one is a Fine-grained Access Token and the second option is Access Tokens(classic).
- You can go for either of the two, but just for this guide, we will go with “Classic Access Token“.
- On the top right corner of this page, click on Generate New Token.
Now in the note, type “test token” here and choose the permissions you want this token user to have.
- If you want to have all permissions, select all of them or you can just select the Repo and Admin permissions and then click on Generate Token.
- Your personal access token will now be shown on the page. If you want to store that token for future use, click the clipboard button next to it to copy it and save it anywhere on your computer.
- Keep this token in a safe place, otherwise, somebody will misuse it.
Finally, run the clone command and it would do the job for you.
3] Remove and then add the credentials
Another reason why GitHub is unable to clone the repository is that there is an issue with your credentials. However, this is not a severe issue and by removing and adding the credentials, your issue will be resolved. Follow the steps given below to do the same.
- Open Credentials Manager from the Search Menu.
- Click on the Windows Credentials option.
- Go to Generic Credentials, expand it, and click on the Remove button from the GitHub section.
Once you have removed the credentials, just log in normally and then clone. Your issue will be resolved.
Also Read: How to download files from Github and view them?
Why I am not able to clone the repository in GitHub?
You are unable to clone the repository in GitHub due to the lack of permission or the wrong URL. The very first thing you need to do is check if the URL is correct. Once you are sure that the URL that you are using is correct, then check if you and GitHub have permission to access the folder let alone clone it. To know more, check out the aforementioned guide.