Azure Repos Git Tutorial

Table of Contents

Overview

Azure Repos provides Git repositories for source control, offering unlimited, cloud‑hosted private repos. It integrates seamlessly with Azure Pipelines, Boards, and other DevOps services.

Setup & Prerequisites

  1. Create an Azure DevOps organization or use an existing one.
  2. Navigate to Repos > Files and click Create a new repository.
  3. Choose Git as the version control system.
  4. Install Git on your local machine.
# Verify Git installation
git --version

Clone a Repository

Copy the clone URL from the Azure Repos UI (HTTPS or SSH) and run:

# Using HTTPS
git clone https://dev.azure.com/YourOrg/YourProject/_git/YourRepo

# Using SSH
git clone git@ssh.dev.azure.com:v3/YourOrg/YourProject/YourRepo

Branching & Merging

Create a feature branch locally and push it to Azure Repos:

# Create and switch to a new branch
git checkout -b feature/login

# Make changes, then stage and commit
git add .
git commit -m "Add login feature"

# Push to remote
git push -u origin feature/login

Pull Requests

After pushing a branch, create a pull request (PR) to merge into main:

  1. Go to Repos > Pull requests.
  2. Click New Pull Request.
  3. Select your source branch and target main.
  4. Add reviewers, work items, and a description.
  5. Click Create and complete the review.

CI/CD Integration

Link your repo to an Azure Pipeline for continuous integration:

# azure-pipelines.yml (basic example)
trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: UseNode@2
  inputs:
    version: '16.x'
- script: npm install
  displayName: 'Install dependencies'
- script: npm run build
  displayName: 'Build project'

Best Practices

Additional Resources