Getting Started with Azure Repos: A Step-by-Step Guide

Rahul Kondi
2 min readJun 12, 2024

--

Introduction: Azure Repos offers powerful Git repositories for source control, enabling teams to collaborate on code seamlessly. In this guide, we’ll walk through the process of setting up a Git repository in Azure Repos, from creating a project to managing code changes and setting up CI/CD pipelines.

Prerequisites

  1. Azure DevOps Account: Sign up for an Azure DevOps account and create a project.
  2. Git Installed: Ensure Git is installed on your local machine.

Step 1: Create a Project in Azure DevOps

  1. Sign in to Azure DevOps: Visit Azure DevOps and sign in.
  2. Create a new project: Click on “New Project,” fill in the details, and click “Create.”

Step 2: Create a Git Repository

  1. Navigate to Repos: In your project, go to “Repos” from the menu.
  2. Create a new repository: Click on “+ New repository,” name your repository, choose “Git” as the type, and click “Create.”

Step 3: Clone the Repository Locally

  1. Copy the clone URL: In the repository, click on “Clone,” and copy the HTTPS or SSH URL.
  2. Clone the repository: Open a terminal, navigate to the desired directory, and run git clone <your-repo-url>.

Step 4: Add Code to the Repository

  1. Navigate to the cloned repository: cd <your-repo-name>.
  2. Add your code files: Create or add your code files.
  3. Stage the changes: git add .
  4. Commit the changes: git commit -m "Initial commit"
  5. Push the changes: git push origin main

Step 5: Manage Code Changes

  1. Make changes to your code: Modify, add, or delete files.
  2. Stage the changes: git add <file-name>
  3. Commit the changes: git commit -m "Describe the changes"
  4. Push the changes: git push

Step 6: Create and Merge Pull Requests

  1. Create a branch: git checkout -b <new-branch-name>
  2. Make changes and commit: git add ., git commit -m "Work on new feature", git push origin <new-branch-name>
  3. Create a pull request: Go to Repos > Pull Requests, click on New Pull Request, select the source and target branches, add a title and description, and click Create.
  4. Review and merge the pull request: Review changes, click Approve, then Complete to merge.

Step 7: Set Up CI/CD (Optional)

  1. Navigate to Pipelines: In your project, go to Pipelines from the menu.
  2. Create a new pipeline: Click on New Pipeline, follow the instructions to set up a build pipeline using your repository.
  3. Configure build and release pipelines: Define the steps for building, testing, and deploying your code.

Conclusion: You’ve now successfully set up a Git repository in Azure Repos and learned how to manage code changes and collaborate using pull requests. Consider setting up CI/CD pipelines to automate your build and deployment processes for a more efficient development workflow.

--

--