How To Add .NET Project Into Azure DevOps Git Repo

Recently Microsoft introduced Azure DevOps, and Azure Repos (Code in VSTS) is one of the great features of it.

Using Azure Repos we can get unlimited cloud-hosted private Git Repos for the project. You have the freedom to work with IDE, Editor, or Git client hosting and support. Semantic code search is made easy as it understands classes and variables, pull requests, and more.

In this session, we will learn what Azure Repos is and how to create a .NET project and add that to Azure DevOps Git Repos so that the team can collaborate.

Step 1. Create a .NET MVC Project, give it a proper name, and click on the OK button.

.NET MVC

It will ask you to choose a Source Control for your project. You can choose TFVC or Git, for more details on version control my article here.

TFVC

Let's select Git here and click on OK, your solution is ready.

Solution

Navigate to Team Explorer and you can see the master branch was created.

 Master branch

 Team Explorer

Let's create a new Project from Azure DevOps, go to your account and click on the Create Project button as shown below.

Azure DevOps

Enter the project name and description and select private project so that only your team can see and work around it.

New project

Once your project has been created, it will redirect you to the Dashboard. Select Repos from the left menu.

Repos

Copy the URL form, 'Clone to your computer'

Computer

Go to your Visual Studio Team Explorer, from the Publish to Remote Repository paste the URL that you have copied and click on 'Publish'

Publish

Enter your Azure DevOps credentials for login.

Microsoft

By default, it will publish your code on the master branch.

 Code

Right-click on the solution explorer and do the commit to push your code in Azure DevOps Repos.

Commit

Enter some comments so that you can keep track of your changes.

 Comments

Git has Distributed Architecture so when we commit it will first create the local commit and when you want to Sync that on Azure Repos just click on 'Sync'

Architecture

It will show all the changes in the Outgoing Commits section, from there you can push it to the main master branch on Azure Repos.

 Outgoing Commits

Azure Repos

On successfully pushing the changes your code will be displayed in the Azure Repos file section as shown in the below screen.

Files

Thank you for reading this, in my next article we will see how to import a Git repo in Azure DevOps and how to clone the Azure Repos with the team.