How to Move Repository From Devops to Github

Overview

Introduction

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.

open Azure DevOps project, then repos section and press the clone button

open Azure DevOps project, then repos section and press 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.

from the sidebar, press the generate git credentials button

from the sidebar, press the generate git credentials button

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.

devops has generated a username and password along with a URL

devops has generated a username and password along with a URL

Import repository

Open the main Github page, locate the new button and click it to create a new repository.

we can create a new repository by pressing the new button from the main page

we can create a new repository by pressing the new button from the main page

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.

just under the create a new repository header is a link to import a repository

just under the create a new repository header is a link to import a repository

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.

Enter the repository URL which was displayed in DevOps and name your new repository

Enter the repository URL which was displayed in DevOps and name your new repository

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.

Github needs to temporarily store your credentials in order to import the repository

Github needs to temporarily store your credentials in order to import the repository

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.

Github has successfully imported the repository

Github has successfully imported the repository

This will preserve all open branches and commit history. Note, I haven't tested this with open pull requests tested thi

Next steps

  • 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.

Conclusion

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.

Additional Reading

Thanks

If you made it all the way down here, thanks for reading my post and enjoy your day.

#mtfbwy