Reading time: 8 minutes
In this post I will explain how to create a repository on Azure DevOps. Clone this very same repository to your local machine and finally commit changes from your local version of repository to remote repository on Azure DevOps.
What is required
- Azure Subscription
- Net Core Web App
- Repository/Repo on Azure DevOps
- GUI for Git
Azure offers a free subscription plan for personal use. It’s easy to subscribe and practice for your own development or upskilling for a job.
Let’s start by creating a project that will contain your repository
Once you have created a subscription we can then go to Azure DevOps home to create a project.
Enter the project name that would be used throughout this tutorial. Project is like a root folder that would contain all your applications that are related to this project.
For example you can have a project with name TestProject that contains Net Core web api as a backend and Angular application as a frontend. Then you have another project with name FileProcessing that contains some backend code. These two i.e. TestProject and FileProcessing are two different projects with their own domains. These serve for different purposes. Therefore as a good practice should be placed into separate projects.
Next thing we need to select Repos from the left pane. On the right section of the page it should show you the next view.
In there let’s choose an option to Initialize with a README or gitignore.
And for our benefit let’s add both. This is a good practice and both of these files should be added to every project. README serves as an initial documentation that caughts developers first attention. Gitignore is like a safeguard for committing file types that should be left out from pushing it to a remote copy repository.
After we click Initialize it should redirect us to this repo page. From there we can edit details and perform some useful actions.
One of them which is important for this tutorial is action called Clone. The name speaks for itself. In other words we are taking original remote code and cloning it to our local machine. This way we are creating an exact copy of code at that moment of time. Whatever you do, this code/branch on your local machine would not affect the remote code until the moment you use any of these three main commands: commit/push/merge. There are other useful commands but for them you can perform your personal research and see the effect of them on your code.
Once you are at the main page for your repo click the Clone button.
On the slide out click Copy button.
We need this URL (uniform source locator) in order to clone this repository to our local location on our machine.
For this tutorial I will use Sourcetree as a GUI for Git. In Sourcetree add a new tab or under the File menu option choose Clone / New…
On the new tab choose Clone or if you used the File menu option it shows you the required interface.
Paste in the repository URL into the first field. In the second field select the location where you want this repository code to live. By adding \DummyAzureRepo we are creating a root folder for this repository on the fly. Click
When we click Clone the master branch is cloned to our local machine. As you can see this branch contains only two files that we specified during initialization.
If you edit any of the files from the location where you cloned this repository Git should detect these changes.
Let’s create Net Core App to show how Git detects changes
Create Net Core App
Open up Visual Studio and select ASP .NET Core Web Application with Angular template.
On configuration screen type in the name of our repository and add the location where you cloned it but without the root folder name since it was already created in previous steps when we clone the repo.
This is how the root folder of this repo looks before.
After you click Create on the next screen you can specify a web application template if you need one. For this tutorial let’s choose Angular.
And this is how it should look like after you clicked Create.
Now if you go to Sourcetree you should see these changes.
Click on Stage All, write Commit description and click Commit.
At this point these changes are still only on your local machine. For it to be sent to a remote location you need to use the Push command.
Make sure you ticked the right branch. For your Remote branch you can choose any you like. For this time we will keep it as it is. If you are happy with what you see then click Push.
Once you have clicked Push Git sends these changes to the remote repository.
Being able to use Git is essential for being a successful software developer/engineer. Additionally it helps you to keep track of what has changed in terms of code. Another important point is that you got a copy of your code in the cloud. Centralized location that you or your team member can access from anywhere in the world where you got an internet connection.