Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't clone private repo on github from SourceTree

A similar issue is described here however, my symptoms are a little different and none of the steps there seemed to work. Nor does the suggestion here work.

I'm attempting to use SourceTree to clone a private repo belonging to github organization of which I am a part. I have full permissions to view and commit to the repo, I can see it online when I log in, AND I can clone just fine with the command line and also via the github desktop application. It only fails in SourceTree.

Further, it is not bad credentials or anything like that, because I can clone, commit and push to my other non-private repos on github using SourceTree with my github credentials.

From the "Clone a Repository" dialog I enter the source URL, which looks something like this:

https://github.com/MyOrgName/reponame.git 

I tab off of that field and it populates the destination path and name fields, but at the bottom of the dialog is a yellow exclamation point with this error:

This is not a valid source path / URL 

If I click the error message, it brings up the "Details" dialog, which states the following (twice for some reason):

remote: Repository not found. fatal: repository 'https://github.com/MyOrgName/reponame.git/' not found remote: Repository not found. fatal: repository 'https://github.com/MyOrgName/reponame.git/' not found 

I have also tried this by adding my username to the url like so:

https://[email protected]/MyOrgName/reponame.git 

but no luck there either.

like image 281
spacemanjosh Avatar asked May 10 '18 00:05

spacemanjosh


People also ask

Can you clone a private GitHub repo?

You also have the option to clone a private GitHub repository using SSH. To do this, you need to start by generating an SSH keypair on your local device. Then add a public key to your GitHub account.

How do I move a private repository to GitHub?

On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. Under "Danger Zone", click Transfer. Read the information about transferring a repository, then type the name of the user or organization you'd like to transfer ownership of the repository to.

Can Sourcetree clone a git repository?

This article will show how to clone a Git repo (repository) using Sourcetree, which can be an instrumental skill if you are part of a development team. It is also helpful if all you want to do is contribute to an open source project. What is a Git repository & what is GitHub?

How to clone a private repository in GitHub?

To clone a private repository from your account or organization, you need to generate a PAT (Personal Access Token) on your Github account, and add it to the command above. *Organization doesn't have PAT generator. 3, Press "Personal access tokens" then press "Generate new token": * If "repo" is not checked, you cannot clone a private repository.

How do I clone a Git repo?

Before cloning a Git repo, you must download and install Sourcetree. Once Sourcetree is installed, you are all set to begin cloning your first Git repo. The following video will show you how to clone a repo from automateNow’s GitHub page so that you can start working on it on your machine.

How to clone GitHub repository with ssh agent?

Now back to SourceTree, go to Tools and click on Launch SSH Agent. Later, click on a small monitor icon in your taskbar. As a result, the Pageant Key List will popup. Then, click on Add Key to add the private key you saved previously. Now go back to your GitHub repository page and try to clone your repository with SSH way.


1 Answers

It happens because SourceTree didn't get some private access from Github while authenticating. So the solution is very simple

  1. Login into your Github account on any browser
  2. From top right corner select SETTINGS
  3. Now select DEVELOPER SETTINGS
  4. From DEVELOPER SETTINGS select PERSONAL ACCESS TOKEN
  5. Now from PERSONAL ACCESS TOKEN select GENERATE TOKEN
  6. Fill Note as sourcetree and Check All Scopes from checkbox as show in below screenshots

  7. After Click on Generate Token enter image description here

  8. Now Open sourceTree

  9. Click on sourceTree preference & Click add Account

  10. Select options as shown in below screen shotenter image description here
  11. Enter username as your Github account username and password as Generated Token from Github
  12. Click on SAVE now you might see all your repository are visible and can clone too

Hope it helps

like image 85
Suresh Maidaragi Avatar answered Oct 05 '22 07:10

Suresh Maidaragi