How to Move Repository From Devops to Github
I wanted to migrate a repository from Azure DevOps repos to Github whilst preserving as much of my content as possible. It turns out it was really straightforward using Github importer. This feature is available for source code in Subversion, Mercurial, Team Foundation Version Control, and Git. I'm looking at migrating a git repository hosted in an Azure DevOps project.
Commit and push your code!
Firstly, you will need to be mindful that git is a decentralised source control system. Changes to your repository occur locally. As such the remote repository will only be aware of changes that have been committed and pushed back. Therefore, if you want to ensure that all changes are migrated, you need to commit them and push them back to the repository before starting this migration. This goes for every person who is contributing to your repository.
Prepare DevOps repository
Firstly, you'll need to get some information from DevOps and set up credentials for Github to authenticate. Open DevOps and navigate to the repos section of the project where the source repository is located. You'll have to have the files section option to see the clone button.
You will then see a sidebar appear with some options. Firstly press the "generate git credentials" button. We'll use these credentials to allow Github to authenticate with DevOps to import the repository.
Azure DevOps will generate a username and password. You will need the URL, the username, and the password during the import process in Github so make a note of them.
Open the main Github page, locate the new button and click it to create a new repository.
Located just under the "create a new repository" header, you'll find a link to import a repository. Click this to start the import process.
First, you'll be asked for the repository's URL and to give the repository a name. This is not the current name of the repository, but what you wish to call it in Github. If you want to give your repository an entirely different name, you can.
You will then be asked for credentials to access the DevOps repository. These are the credentials that Azure DevOps generated earlier. These will be stored temporarily during the import process.
And that is it! After a short period, Github will report that the import is complete. You will then find your repository available to access from Github.
This will preserve all open branches and commit history. Note, I haven't tested this with open pull requests tested thi
- This is a non-destructive action, so you may want to archive the Azure DevOps repository to ensure that work doesn't continue in two places.
- Your local version of the repository will currently be pointing at the Azure DevOps repository. If you wish to work on the Github version you will need to fix this. You have a few options here;
- change the remote URL of your local repository
- remove the current folder and re-clone
- clone the Github repository to a new location
- You may also wish to update the referenced repository so that the Github version is available in Azure DevOps.
I'll look at these things in future posts.
We've successfully migrated a git repository from Azure DevOps to Github and preserved the commit history and all branches. Not all functionality is available to each source code system, so refer to the Github docs for more information.