Introduction

If you are a beginner, kindly take a look at my previous article for a better understanding.

It's very easy to add an existing repository from a local repository to Git in Visual Studio. It works wonderfully for a .NET project but if I have a file with a .java extension or any other, in my local repository, how can I add that to Git with Azure DevOps? This is a major question but you can get its answer from my previous article. Here comes the next article of the Azure DevOps series; i.e., how to add an existing repository to Git using the command prompt. By this method, you can add any kind of existing file from a local repository to the Git repository.

Get Started

As usual, create a new repository and add a README file. Once it is created, click on it; you will find the README file in your repository. In the right corner, you will find the "Clone" option. Click on it and you will find the options of using HTTPS and using Git credentials. Here, I am using a remote repository URL. Just take a look at it and copy the URL to Notepad.

 URL

Clone

Open Command prompt

Just follow the steps as given, the images are for reference. Commands are clearly explained by using a highlighter. Here, images are just for understanding the flow.

Open Azure DevOps

Check if the file you added to the local machine is pushed to the Git server or not. Just open the project in Azure DevOps and refresh/reload. You can see the file is pushed from the local machine to the Git server.

As a final output, the file you added to your local repository is cloned to the Git repository with Azure DevOps. Now, you can see the java.java file in your Azure DevOps.

Azure Devops

MydemoProject

Summary

I hope this was interesting. Stay tuned for upcoming articles in the Azure DevOps series. In case of any doubts, don't hesitate to drop me a comment.