GitHub Desktop and Azure DevOps

A peer of mine recently asked about how I manage local code (projects, solutions, Git repos, etc.) that may or may not be synced to a cloud repository (GitHub, Azure DevOps, etc.)  Since I previously blogged about How I Blog – Updated 2018 and I’m a fan of re-using how many keys I have left I thought I would share my personal local development process.

Disclaimer

I like to to tell people that “I play a developer on TV”, meaning it has been at least 10 years since I’ve written code as a consultant that was actually deployed to a production system.  Sure I’ve written (or collaborated on) many samples (ex. .Net Core console sample for Microsoft Graph) and proof of concepts for customers these past 10 years, but it wasn’t the primary focus of my job.  So balance everything that I share with what others such as my friend Steve Smith (@Ardalis) share on his Weekly Dev Tips blog and podcast.

Local Folder Structure

Currently I develop on Windows so folders and paths will reflect that.  I don’t use the default folder that any of the IDEs or tools below use (generally under my user profile folder such as “c:\Users\[username]\…”).  Instead I create a new folder called Projects at the root of my primary drive (i.e. “c:\Projects”).  Below that folder I then have the following:

  • c:\Projects\_DevOps
  • c:\Projects\_GitHub
  • (All other local-only projects, ex. c:\Projects\localProject1)

Using the underscore for _DevOps and _GitHub means that those folders should be easy to find at the top of this folder structure even if I happen to inadvertently sort the folder.

As for project folders, I’ve thought about subdividing based on topic (ex. SharePoint Online, Azure, Microsoft Graph, etc.) or technology (ex. ASP.NET Core, Blazor, Console, etc.) but since I rarely have a large number of folders I haven’t done anything yet.  I do name my folders and projects based on topic though (ex. BTJ.SPO.ProjectName, BTJ.AZ.ProjectName, BTJ.MG.ProjectName, etc.)  This helps at least group together similar projects.

Git / GitHub / Azure DevOps Tools

I use a mix of the following tools to sync my repos and monitor issues or pull requests.

  • Visual Studio Code (VS Code) – VS Code has integrated supported in-box for Git.  I use this for committing and pushing code to my GitHub repositories.
  • Azure Repos Extension for Visual Studio Code – There is an extension for VS Code that adds additional functionality (ex. monitor builds, pull requests, and more) directly into VS Code.

  • GitHub Desktop client – GitHub offers a desktop client that allows you to sync code, create branches, review commit history, and more.  When I’m not directly in VS Code working on a repo I generally use GitHub Desktop.
  • Visual Studio Team Explorer – In general I start most projects in VS Code these days.  For the projects I do work in Visual Studio 2019 (ex. Blazor and some ASP.NET Core) I use the Team Explorer functionality (now available out of the box) to sync repos.  The integration with Azure DevOps and GitHub is good as well.
  • GitHub mobile app – I do submit and review a GitHub issues or pull requests on an infrequent basis.  When I am not at my desk I tend to use the newly released mobile app for GitHub.
  • Browser based pull requests – Some repositories that I collaborate on are very large and not well suited to sync locally (ex. Azure docs, Microsoft Graph docs, etc.)  For these I prefer submitting a pull request directly in the browser.  I previously blogged about this at How to Edit Microsoft Documentation on GitHub.

Conclusion

I hope you have found something useful in this post.  Please share your own suggestions or recommended tools / processes in the comments below.  Happy coding!

-Frog Out

Azure DevOps Services | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018 - TFS 2013

Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015

You can create a local copy of a remote Git repo by cloning it into a local folder on your computer. Cloning a remote repo downloads all commits on all branches of the repo, unless you use the --single-branch clone option. Cloning links each branch in your new local repo with the corresponding branch in the remote repo. That way, when you push to share your local branch changes with your team, the corresponding remote branch is updated. Similarly, when you pull to update your local branch with changes made by your team, updates from the corresponding remote branch are retrieved. The remote repo can be an Azure Repos Git repo, a GitHub repo, or other hosted Git repo.

This article provides procedures for the following tasks:

  • Get the clone URL for an Azure Repos Git repo
  • Get the clone URL for a GitHub repo
  • Clone an Azure Repos Git repo
  • Clone a GitHub repo
  • Clone any Git repo
  • Open a Visual Studio solution from a cloned repo

For an overview of the Git workflow, see Azure Repos Git tutorial.

Prerequisites for access to Azure Repos

  • Repos must be enabled in your Azure DevOps project settings. If the Repos hub and associated pages don't display, see Turn an Azure DevOps service on or off to reenable Repos.

  • To view code in private projects, you must be a member of an Azure DevOps project with Basic access level or higher. For public projects, everyone can view the code.

  • To clone or contribute to code for a private project, you must be a member of the Contributors security group or have the corresponding permissions set. For public projects, anyone can clone and contribute code. To learn more, see What is a public project?

    Note

    For public projects, users granted Stakeholder access have full access to Azure Repos.

  • Repos must be enabled in your Azure DevOps project settings. If the Repos hub and associated pages don't display, see Turn an Azure DevOps service on or off to reenable Repos.

  • To view code, you must be a member of the Azure DevOps project with Basic access or higher. If you aren't a project member, get added.

  • To clone or contribute to code, you must be a member of the Contributors security group, or have the corresponding permissions, in the project you want to change.

  • To view code, you must be a member of an Azure DevOps project with Basic access or higher. If you aren't a project member, get added.

  • To clone or contribute to code, you must be a member of the Contributors security group or have the corresponding permissions.

Get the clone URL of an Azure Repos Git repo

Typically, you need to know the clone URL of the remote repo that you want to clone. The clone URL uniquely identifies the remote repo.

Note

When you're signed into an Azure DevOps project, Visual Studio supports searching for and cloning project repos without needing to know the clone URL.

  1. From your web browser, open the team project for your Azure DevOps organization, and then choose Repos > Files to open the Files view.

    GitHub Desktop and Azure DevOps

  2. In the Files view, choose Clone to launch the Clone Repository popup.

    GitHub Desktop and Azure DevOps

  3. Copy the clone URL from the Clone Repository popup.

    GitHub Desktop and Azure DevOps

Get the clone URL of a GitHub repo

Typically, you need to know the clone URL of the remote repo that you want to clone. The clone URL uniquely identifies the remote repo.

Note

When you're signed into GitHub, Visual Studio supports searching for and cloning GitHub repos without needing to know the clone URL.

  1. Open a browser and navigate to your GitHub account, select the Repositories tab, and choose the repository to clone.

    GitHub Desktop and Azure DevOps

  2. On the GitHub repository page, choose Code to launch the Clone popup. Copy the clone URL from the Clone popup.

    GitHub Desktop and Azure DevOps

Clone an Azure Repos Git repo

By signing in as a member of an Azure DevOps project, you can clone private repos that are accessible to you, and public repos. Visual Studio supports search, clone, and sync operations on repos that are accessible through authentication.

  • Visual Studio 2019
  • Visual Studio 2017 & earlier
  • Git Command Line

Visual Studio 2019 version 16.8 and later versions provides a Git version control experience while maintaining the Team Explorer Git user interface. To use Team Explorer, uncheck Tools > Options > Preview Features > New Git user experience from the menu bar. You can use Git features from either interface interchangeably. Below, we provide a side-by-side comparison for cloning an Azure Repos Git repo.

  1. From the Git menu on the menu bar, choose Clone Repository to open the Clone a repository window.

GitHub Desktop and Azure DevOps

  1. In the Clone a repository window, select Azure DevOps under Browse a repository to open the Connect to a Project window.

GitHub Desktop and Azure DevOps

  1. In the Connect to a Project window, sign in to Azure DevOps and choose the remote repo you want to clone. You can use the search box to filter the list of remote repos. If you don't see the remote repo, select Add Azure DevOps Server to add the server that hosts the repo. Verify the local folder path where you want the local clone to be created, and then select Clone.

GitHub Desktop and Azure DevOps

Visual Studio Team Explorer

  1. In Team Explorer, select Connect to open the Connect page, and then choose Manage Connections > Connect to Project.

GitHub Desktop and Azure DevOps

  1. In the Connect to a Project window, sign in to Azure DevOps and choose the remote repo you want to clone. You can use the search box to filter the list of remote repos. If you don't see the remote repo, select Add Azure DevOps Server to add the server that hosts the repo. Verify the local folder path where you want the local clone to be created, and then select Clone.

GitHub Desktop and Azure DevOps

After you've cloned a remote Git repo, Visual Studio detects the local clone and adds it to the list of Local Repositories in the Git menu.

GitHub Desktop and Azure DevOps

  1. In Team Explorer, open the Connect page by selecting the Connect button. Choose Manage Connections then Connect to Project.

    GitHub Desktop and Azure DevOps

  2. In Connect to a Project, select the repo you want to clone from the list and select Clone.

    GitHub Desktop and Azure DevOps

    If you don't see your repo listed, filter the list to find it. You may need to add an Azure DevOps Server where the repo is hosted. Select the Add Azure DevOps Server link.

  3. Verify the location of the cloned repo on your PC and select Clone.

To clone an Azure Repos Git repo from the command line, see Clone any Git repo.

By signing into GitHub or using SSH authentication, you can clone private repos that are accessible to you, and public repos. Visual Studio supports search, clone, and sync operations on repos that are accessible through authentication.

Note

You can clone a public GitHub repo without signing in to GitHub or otherwise authenticating. To clone a public Git repo without signing in, see Clone any Git repo.

  • Visual Studio 2019
  • Visual Studio 2017 & earlier
  • Git Command Line

Visual Studio 2019 version 16.8 and later versions provide a Git version control experience that supports search, clone, and sync operations on GitHub repos that are accessible through authentication. To clone a GitHub repo using Team Explorer, see Clone any Git repo. The following steps apply to the Git version control experience.

  1. From the Git menu on the menu bar, choose Clone Repository to open the Clone a repository window.

    GitHub Desktop and Azure DevOps

  2. In the Clone a repository window, select GitHub under Browse a repository to open the Open from GitHub window.

    GitHub Desktop and Azure DevOps

  3. In the Open from GitHub window, sign in to GitHub and choose the remote repo you want to clone. You can use the search box to filter the list of remote repos. Verify the local folder path where you want the local clone to be created, and then choose Clone.

    GitHub Desktop and Azure DevOps

After you've cloned a remote Git repo, Visual Studio detects the local clone and adds it to the list of Local Repositories in the Git menu.

GitHub Desktop and Azure DevOps

To clone a GitHub repo using Team Explorer, see Clone any Git repo.

To clone a GitHub repo from the command line, see Clone any Git repo.

Note

You can also clone a GitHub repo from the command line by using the GitHub CLI.

You can clone any Git repo that's accessible to you by using the clone URL of the repo.

  • Visual Studio 2019
  • Visual Studio 2017 & earlier
  • Git Command Line

Visual Studio 2019 version 16.8 and later versions provides a Git version control experience while maintaining the Team Explorer Git user interface. To use Team Explorer, uncheck Tools > Options > Preview Features > New Git user experience from the menu bar. You can use Git features from either interface interchangeably. Below, we provide a side-by-side comparison for cloning any Git repo.

  1. From the Git menu on the menu bar, choose Clone Repository to open the Clone a repository window.

GitHub Desktop and Azure DevOps

  1. In the Clone a repository window, enter the clone URL of the remote Git repo that you want to clone, verify the local folder path where you want to create the local clone, and then choose Clone.

GitHub Desktop and Azure DevOps

Visual Studio Team Explorer

  1. In Team Explorer, select Connect to open the Connect page, and then choose Clone under Local Git Repositories.

GitHub Desktop and Azure DevOps

  1. Enter the clone URL of the remote Git repo that you want to clone, verify the local folder path where you want to create the local clone, and then choose Clone. To clone the remote Git repo and any Git repos that are nested within it, leave Recursively Clone Submodules checked.

GitHub Desktop and Azure DevOps

After you've cloned a remote Git repo, Visual Studio detects the local clone and adds it to the list of Local Repositories in the Git menu.

GitHub Desktop and Azure DevOps

  1. In Team Explorer, open the Connect page by selecting the Connect button. Choose Manage Connections then Connect to Project.

    GitHub Desktop and Azure DevOps

  2. Select Clone under Local Git Repositories and enter the URL for your Git repo. Your team or Git hosting provider gives you this URL.

  3. Select a folder where you want your cloned repo, and then choose Clone.

    GitHub Desktop and Azure DevOps

git clone

The Git clone command also let's you specify a folder path after the clone URL to create the repo in a specific location. For example:

git clone https:///fiber-teams/FiberTests/_git/FiberTests C:\Repos\FiberTests

The Git clone command also let's you clone just a single branch. This option is useful when only one branch of a large repo is of interest to you.

git clone --single-branch

Note

When you clone a remote repository, Git assigns the alias origin as shorthand for the URL of the remote repo you cloned. Git commands often use that alias.

  • Visual Studio 2019
  • Visual Studio 2017 & earlier
  • Git Command Line

Visual Studio 2019 version 16.8 and later versions provides a Git version control experience while maintaining the Team Explorer Git user interface. To use Team Explorer, uncheck Tools > Options > Preview Features > New Git user experience from the menu bar. You can use Git features from either interface interchangeably. Below, we provide a side-by-side comparison for opening a Visual Studio solution from a cloned repo.

  1. Choose the File > Open > Project/Solution from the menu bar, and select the solution file to open.

GitHub Desktop and Azure DevOps

  1. The Visual Studio solution that you selected is now open in Solution Explorer.

GitHub Desktop and Azure DevOps

Visual Studio Team Explorer

  1. Right-click on a repository in the Connect view of Team Explorer and choose Open.

GitHub Desktop and Azure DevOps

  1. In the Home view of Team Explorer, double-click your solution file under Solutions.

GitHub Desktop and Azure DevOps

  1. The Visual Studio solution that you selected is now open in Solution Explorer.

GitHub Desktop and Azure DevOps

  1. Right-click on a repository in the Team Explorer Connect view and select Open.

    GitHub Desktop and Azure DevOps

In the Home view in Team Explorer, double-click your project solution file in the Solutions area. The solution opens in Solution Explorer.

GitHub Desktop and Azure DevOps

At the command prompt, run the following command to open a Visual Studio solution from a cloned repo. This command isn't a Git command.

start

For example:

start C:\Repos\FiberTests\FiberTests.sln
  • New to Git repos? Learn more