Getting Started with Azure Repos: A Step-by-Step Guide
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
- Azure DevOps Account: Sign up for an Azure DevOps account and create a project.
- Git Installed: Ensure Git is installed on your local machine.
Step 1: Create a Project in Azure DevOps
- Sign in to Azure DevOps: Visit Azure DevOps and sign in.
- Create a new project: Click on “New Project,” fill in the details, and click “Create.”
Step 2: Create a Git Repository
- Navigate to Repos: In your project, go to “Repos” from the menu.
- 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
- Copy the clone URL: In the repository, click on “Clone,” and copy the HTTPS or SSH URL.
- 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
- Navigate to the cloned repository:
cd <your-repo-name>
. - Add your code files: Create or add your code files.
- Stage the changes:
git add .
- Commit the changes:
git commit -m "Initial commit"
- Push the changes:
git push origin main
Step 5: Manage Code Changes
- Make changes to your code: Modify, add, or delete files.
- Stage the changes:
git add <file-name>
- Commit the changes:
git commit -m "Describe the changes"
- Push the changes:
git push
Step 6: Create and Merge Pull Requests
- Create a branch:
git checkout -b <new-branch-name>
- Make changes and commit:
git add .
,git commit -m "Work on new feature"
,git push origin <new-branch-name>
- Create a pull request: Go to
Repos > Pull Requests
, click onNew Pull Request
, select the source and target branches, add a title and description, and clickCreate
. - Review and merge the pull request: Review changes, click
Approve
, thenComplete
to merge.
Step 7: Set Up CI/CD (Optional)
- Navigate to Pipelines: In your project, go to
Pipelines
from the menu. - Create a new pipeline: Click on
New Pipeline
, follow the instructions to set up a build pipeline using your repository. - 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.