How to use Azure DevOps Git Repos for the first time?

I used Visual SourceSafe for source control many many years back. I later used TFS (Team Foundation Server) from the beta version to today's latest version, VSTS which is now Azure DevOps.

Some years back I started playing with "Git", the distributed version control system , when there was no integration in Visual Studio whatsoever.

Today, Microsoft offers TFVC (Team Foundation Version Control) and TFGit as first class citizens in Team Foundation Server or Azure DevOps.

I usually tell developers on teams I help Setup development environments that it is really a matter of preference in certain circumstances.

Now, if your team members are geographically dispersed and you want them to access source code over the internet, you are going to have to use Git or some other distributed source control systems.

But if all your team members are all in the same campus network or can remotely access the Team foundation server,  then, it is really a matter of preference (Read Git(TFGit) vs TFVC).

Azure DevOps that was recently launched to replace Visual Studio Team Services, will almost force you to go with the Microsoft implementation of Git (especially if you need to setup public repos).

The steps I am giving below assume that you don't have any IDE integration (or even if you do, the command line option will only make your overall experience more pleasant).

Over the past days, I decided to launch a small but useful intellectual exercise:
Setup a team project in Azure DevOps, Simulate a Scrum agile process, use git for my repos. The project is simply to track all my study session, practice code and tests in preparation for Exam70-487.

I created a sample ASP.NET MVC application in Visual Studio 2017 and pushed my initial code to my Exam70487 repos found here:
https://rogerwamba.visualstudio.com/Exam70487

The first thing after the project is created is to open it in Azure DevOps and click "Clone"

Copy the HTTPS or SSH repo url (https://rogerwamba.visualstudio.com/Exam70487/_git/Exam70487)

I will also recommend to get the credentials by clicking the "Generate Git credentials" button:

That's it for the Azure DevOps side.

Now, back in your local development machine:
Make sure you install Git for Windows on your computer if not already done:
Download it at https://git-scm.com/downloads
You can safely just pick the default option.

Once you are done, just navigate to the folder where your code is and do this:
Right click anywhere in the folder and select "Git Bash here", you will a window like this:

Type "git init": This will turn your folder into a git-aware workspace or git local repository where you could track your changes
Next, link your local repo to the remote repo in Azure DevOps:
git remote add origin https://rogerwamba.visualstudio.com/Exam70487/_git/Exam70487

Add your files to the local repo:
git add .

Commit your changes to your local repo
git commit -m "Initial Commit"

Configure a global username

$ git config --global user.email "user@someDomain.com"

Push your local changes to the remote repo
git push -u origin --all


Now all your files are in your remote repository (way easier from IDE, but I think it is a good practice to know this route as well).



Happy source code control  with Git!


Comments

Popular posts from this blog

Why can't Microsoft install IIS on Window Operating Systems by default?

Exam 70-487: Accessing Data - How to choose the Appropriate Data Access Technology - Entity Framework?

Exam 70-487: Accessing Data - How to choose the Appropriate Data Access Technology - Azure Cosmos DB?