Migrate a repository from GitHub to Visual Studio Online

By | 2014-03-14T11:32:25+00:00 March 14th, 2014|Visual Studio 2013|7 Comments

When I thought about moving a GitHub repository to Visual Studio Online, I assumed that Microsoft would do everything in its power to make it difficult for me to clone it. It succeeded a little – you can’t actually use just the IDE to migrate your repo; you’ll need to jump from the IDE to the Command Prompt to add a remote. But at least it works smoothly!

N.B. If you’re following along exactly, make sure that the Visual Studio Online repo that you’re migrating to is empty before you start. Otherwise, you’ll probably get some merge conflicts.

Create a new Team Project with Git as the version control type in Visual Studio Online. I’ve called mine “My GitHub Repo”.


Connect to it from Visual Studio 2013, Team Explorer:



Clone the repo by clicking the “Clone this repository” link:



Open up Command Prompt in the “Changes” window and “Actions:”


Then, add a remote for the GitHub repo. If we ever need to pull down commits from the repo that are located on GitHub, we can do that by pulling from the remote name rather than the long GitHub URL. The command is:

git remote add


To pull down your changes from that new remote you just added:

git pull master


And don’t forget to push your changes from your local repo up to the Visual Studio Online server (which is origin by default):

git push origin master


If you have more than one branch, you’ll have to repeat the last three steps for as many branches are in your GitHub repo that you want, with a couple of additions.

To check the branches located on your GitHub repo:

 git branch –a

branch2 github

To track a branch from GitHub:

git branch <branch> <remotes/<remote name>/<branch>

Example: git branch FeatureBranch remotes/GitHub/FeatureBranch

track branch github

Then, push ‘em on up to origin with git push origin <branch>.

Check out the result of pulling down from GitHub and pushing up to the Visual Studio Online repo:


And coincidentally, I pulled a repository from GitHub that had a subtree in it, so that was cloned into our repo as well!

So there you have it, migrating from GitHub to Visual Studio Online in a nutshell.



About the Author:


  1. Stu March 17, 2014 at 1:53 pm

    What are the advantages in doing this? What does Visual Studio Online have over github?

  2. mitja.gti June 13, 2014 at 8:18 am

    Very simple. It has ALM capabilities. Visual Studio Online is basically an online Team Foundation Server.

  3. Tesla February 20, 2015 at 8:45 am

    Thank you very much. This works perfectly. Before reading this, I used to copy paste code directories. This is much more structured.

  4. Sachi Williamson February 20, 2015 at 11:53 am

    Glad to hear that this was helpful, Tesla! 🙂

  5. ztheterrible February 22, 2015 at 11:44 am

    Absolutely awesome!!!! Thanks for this!

  6. João Vicente L. F. Machado April 6, 2016 at 2:32 pm

    Hi Sachi, great article! It worked fine, thanks a lot! Question: It’s OK to delete the GitHub’s repository after a successful migration without affecting the new VSO’s repository?

  7. Sachi Williamson April 13, 2016 at 8:12 pm

    Hi João, glad it worked! As long as you have all of the branches (and tags) from GitHub to your local machine that you need, you should be able to delete the GitHub repository. If you’re worried about not having a backup copy of everything from GitHub, you can always clone it to your local machine: https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository#Cloning-an-Existing-Repository. You may also want to delete the reference to the remote on the local repo: https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes#Removing-and-Renaming-Remotes. The VSO repo and GitHub repo are each their own repos. Let me know if you have more questions!

Leave A Comment