We've recently made a decision to move our source control, project management and build functions away from Azure DevOps and over to GitHub. The reasons behind the decision will be covered in another blog post but the first step in the process has been to migrate our Git repositories from Azure DevOps over to GitHub.
When it comes to migrating our repository there are two ways we can approach the task:
- We can use the import tool on the GitHub website OR
- We can use the command line
This post will cover using the import tool on the GitHub website but we have a follow on post which covers the same process using the command line.
Using the import tool on the GitHub website
Importing the repository
To use the import tool provided on the GitHub website your repository will need to be available on the public internet so GitHub can connect to it. While this is fine for migrating from Azure DevOps it does mean that this approach isn't suitable for Git repo's hosted internal to your company network.
Before we do anything in GitHub lets head over to Azure DevOps and get the URL and credentials GitHub will use to connect to our repository. You can find all of this information by clicking on the Clone button at the top right of your repository.
When you click the button it will bring up the Clone Repository window which shows the HTTPS URL of your repository at the very top. To access the credentials GitHub will use to connect to the repository you'll need to hit the Generate Git Credentials button.
The generated credentials will appear where the button was previously. Take a note of the HTTPS URL, Username and Password. We'll need them when we begin the import in GitHub.
We're now ready to head over to GitHub and access the Import Repository tool from the + menu at the top right of the screen.
Now we can enter the HTTPS URL of our Azure DevOps repository, enter a name for the repository on GitHub and specify whether it should be public or private. Once we've entered all of that information we can click on the Begin Import button.
After a few seconds you'll be prompted to enter the Git credentials you generated on Azure DevOps. Once they are entered you can hit the Submit button to carry on.
GitHub will now connect to Azure DevOps and import your repository. Depending on how large your repository is this step could take some time and the good news is that you now the process has been initiated you can close the window and move on to working on something else. GitHub will send you an email once the process has completed.
If you do hang around you'll eventually see an import complete message.
Re-pointing local clones to GitHub
Although our repository has now been migrated to GitHub any clones on our local machine are still pointing to Azure DevOps which is no longer correct.
We could simply delete any local clones of the repository and clone them fresh from GitHub but that seems pretty time consuming so instead we'll re-point our local clone from Azure DevOps to GitHub.
git remote -v from the command line will show the current origin for any repository. As you can see for our
migration-test repository this is still pointing to Azure DevOps.
To update the URL of a remote we can use the
git remote set-url command passing in the name of the remote we want to update,
origin in this case, and the new remote URL which will be the GitHub clone URL for your repository. Altogether the command will look like this:
git remote set-url origin https://github.com/sidebytes/migration-test.git
If we run
git remote -v again we should see the updated remote URL's and any changes we push will go to GitHub rather than Azure DevOps.
Remember to also update any CI/CD pipelines or other tools which access your repository.
In this post we showed how to migrate a repository from Azure DevOps to GitHub using the GitHub website. In the next post we'll cover the same process but done completely from the command line.
Thinking of migrating from Azure DevOps to GitHub?
We can assist in all aspects of your migration from business case through to implantation. Please don't hesitate to get in touch at email@example.com.