3
votes

Visual Studio can connect to an Azure DevOps project through Team Explorer by adding a new Team Project connection.

By connecting to a Team Project (hosted in Azure DevOps), one is able to see the Work Items, Builds and more:

Team Explorer options for a connected Team Project

There is a problem, however, when the aforementioned project in Azure DevOps is not using Azure DevOps internal Git repository, but instead, is using an external GitHub repository.

In Azure DevOps, this external GitHub repository was set up in: Project Settings --> Boards --> GitHub connections and the units of work (e.g. tasks) are successfully linked to commits in the GitHub repo.

Visual Studio only provides support for the Team Project's internal Git repository, which is empty because an external GitHub repository is being used instead.

If Visual Studio is connected to the GitHub repository directly, then all Git commands are available, but the Team Project link is lost and things like "Work Items", "Builds", etc. are no longer available. On the other hand, by connecting to the Azure DevOps Team project these are available, but the source code repo (in GitHub) is no longer available.

Both options seem to be mutually exclusive. Is there a way to be able to connect to an Azure DevOps Team Project while using the external GitHub repository at the same time (instead of Azure DevOps unused internal Git repository)?

2

2 Answers

2
votes

There is a bit of a trick... A lot of functionality in Visual Studio depends on the origin remote. If there are multiple remotes, Visual Studio will light up the functionality of the provider that is referenced by the origin remote. So when your local repo has multiple remotes, one to Github and one to Azure Repos, the additional functionality of the provider in the origin remote will activate. You can still push/fetsh/pull from either remote in this case.

So:

  • Create a repo on Azure Repos (initialize it as a bare repo wih no README or .gitIgnore).
  • Clone it in Visual Studio from the connect window
  • From the repository setting or the commandline add a second remote to point to your Github project.
  • Pull the contents from the Github project

Or:

  • Create a Repository in Azure Repos and copy the clone url
  • Rename the existing remote in your local git repository to github
  • Add the Azure Repos remote to your local repository under the name origin
  • Use the Connect to project... window to connect to the Azure Repos repository. Then open the local git repo from the Local Repositories.
  • Visual Studio should link the two up.

You can then ignore the origin remote. It purely serves Visual Studio to tell it to activate the Azure Boards and Azure Pipelines features.

This should let Visual Studio think the project is hosted primarily on Azure DevOps and you'll be able to push and pull on GitHub as well.

0
votes

No. Azure DevOps and GitHub, although both owned by Microsoft, are separate services.