Moving repository from Team Services to GitHub

Image from:

When I was establishing the connection between the Team Services and the GitHub I hoped that I will be able to push the code to the Team Services and the Team Services will redirect it to the GitHub. But this doesn’t work this way. After I had pushed the code to the Team Services my GitHub repository was still empty.

My expectations were wrong. In fact, the code has to be pushed directly to the GitHub omitting Team Services. So what do we do now? I can try to simply remove the repository from Team Services and start a new one on the GitHub, or I can move the repository from the Team Services to the GitHub. The second solution seems to be more difficult. So I decided to try the second one.

Importing a Git repository using the command line.

Several ways to move the repository are described on the GitHub Help pages. I chose to do this using the command line. I described it in detail below.

  1. First, create the directory to have a place for the cloned repository. Then go to this directory.
  2. Next, follow the GitHub documentation and make a bare clone of the repository:

    On the command line make a “bare” clone of the repository using the external clone URL. This creates a full copy of the data, but without a working directory for editing files, and ensures a clean, fresh export of all the old data.

    What it looked like in my case:

  3. Push the repository to the GitHub.

    Push the locally cloned repository to GitHub using the “mirror” option, which ensures that all references, such as branches and tags, are copied to the imported repository.

    During the push, you will probably be asked for your GitHub login and password.

    After this step, you should have your repository on the GitHub.

  4. And finally, last but not the least, clean up the mess.

    Remove the temporary local repository.

    And remove the repository from the Team Services.

Switching Visual Studio remote repository from the Team Services to the GitHub.

So the repository is on the GitHub but Visual Studio is still connected to the Team Services’ repository.

To change it to the GitHub, go to the Team Explorer Repository Settings and under Remotes click Edit and replace repository address with the one from the GitHub.

The last thing to do is to clone the repository.

Now Visual Studio is connected to the Team Services and to the GitHub repository at the same time. The Team Services is able now to do several things with the code like: build it, run tests, publish etc.

Unfortunately, the code stored on the GitHub isn’t visible in the Team Services.

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *