'Clone URL is incorrect' when importing from GitHub to Azure DevOps
Got the very same problem when trying to make a fresh new import of a private GitHub repo managed by an Organization to my new Azure DevOps account (even though my account is the owner of both GitHub and Azure DevOps profiles I was trying to link).
Three steps actually helped me to resolve it:
-
Link two accounts via Azure DevOps > your project > Project Settings > GitHub connections. If your GitHub repo is stored in an Organization profile, here you have to make sure that you grant access to this Organization while you're setting up the connection in Azure DevOps (there will be a small Grant button next to the identified Organization profile in Azure DevOps, you have to press it to actually grant the access). In my case I missed it and the connection did not work (Azure DevOps couldn't find any repos in the GitHub profile). To resolve this, I had to follow the link from an automatic e-mail sent to me by GitHub and grant access to Azure DevOps there. Then in Github > your organization > Organization Settings > Third-party access you will be able to see Azure DevOps in the list - if the status is Approved, you're good to go.
-
Then I had to create a PAT for my personal profile in GitHub (NOT the Organization profile) and use it instead of the password when I was importing the repo in Azure DevOps (big thanks to @Yang Shen who pointed this out above). This way you first have to go to Github > your profile > Profile Settings > Developer Settings > Personal access tokens and generate a new token there.
-
Then I returned to Azure DevOps > your project > Repos > Files > Import, putting in: a) Link to my private Github repo; b) Tick "Authentication required"; c) My GitHub username; d) My PAT generated at Step 2 above instead of my actual password
Then it worked like a charm, my private Github repo was cloned to Azure Repos.
I just recognized "Generate Git Credentials" does the trick!
In your source repos, you must "Generate Git Credentials"
In your dest repos where you click import use the "Clone Url" from source and enter the generate Git credentials!
I've tested the Import a Git repository
in sevral situations: public or private Github repo, with or without access in PAT and with or without file in Github repo.
Only in two cases i can reproduce the problem:
-
No file exists in the Github repo, if there's nothing in the Github repo, seems the url
https://github.com/****/*****.git
can not be recognized successfully.In this case, you need to upload at least one any file into the repo and the url will be recognized then.
-
Wrong PAT, we copy PAT from one place to another, there might be unexpected characters included, such as a space.
In this case, you need to check the PAT by click the little eye icon in the input textbox, delete or add characters to make it correct.
For me, it was because the GitHub repo I wanted to copy was Private.
Make it Public and try again.
- Go to the GitHub repo you want to import, on the Settings's page change the visibility to Public.
- Copy the .git (HTTPS) URL of the repo.
- On Azure, paste the link and click on Import.
My GitHub repo Settings' page
I found the solution!
-
In your GitHub account, go to your icon in the top right corner and then click on Settings
-
In the left sidebar, click on Developer settings
-
Then in the left sidebar again, click on Personal access tokens
-
Click the button Generate new token
-
Give the token a name, e.g. 'Move to Azure'
-
Set the Expiration to however long you need it to be for your move
-
Under Select scopes, tick repo
-
Click on the green button labeled: Generate token
-
Copy your token (save it in a password safe if you have multiple repos)
-
In Azure, paste it into the field Password / PAT
-
After you've moved all repositories, don't forget to delete your Personal Access Token from GitHub