Bird
Raised Fist0
Azurecloud~30 mins

Azure Repos for source control - Mini Project: Build & Apply

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Azure Repos for Source Control
📖 Scenario: You are working on a small team project. To keep your code safe and organized, you want to use Azure Repos for source control. This will help you save your code online, track changes, and collaborate with your teammates easily.
🎯 Goal: Set up a basic Azure Repos repository with an initial README file, configure a branch policy, and create a pull request to merge changes. This will simulate a simple source control workflow using Azure Repos.
📋 What You'll Learn
Create a new Azure Repos repository named TeamProjectRepo
Add a README.md file with the exact content: # Team Project Repository
Create a branch policy that requires at least one reviewer before merging to main
Create a pull request from a feature branch named feature/update-readme to main
💡 Why This Matters
🌍 Real World
Teams use Azure Repos to safely store and manage their code, track changes, and collaborate on software projects.
💼 Career
Understanding Azure Repos is essential for developers, DevOps engineers, and cloud professionals working in Microsoft Azure environments.
Progress0 / 4 steps
1
Create Azure Repos repository with README
Create a new Azure Repos repository called TeamProjectRepo. Add a file named README.md with the exact content # Team Project Repository in the root folder.
Azure
Hint

Think of the repository as a folder online. The README.md is a simple text file that describes your project.

2
Configure branch policy for main branch
Add a branch policy to the main branch of TeamProjectRepo that requires at least one reviewer before any pull request can be completed.
Azure
Hint

Branch policies help keep your main code safe by requiring someone to check changes before merging.

3
Create feature branch and update README
Create a new branch called feature/update-readme from main. In this branch, update the README.md file by adding a new line exactly: Updated README for team collaboration.
Azure
Hint

Branches let you work on changes without affecting the main code. Updating README.md shows your change.

4
Create pull request to merge feature branch
Create a pull request from the branch feature/update-readme to main in TeamProjectRepo. The pull request should have the title Update README for collaboration and description This PR updates the README to improve team communication.
Azure
Hint

A pull request asks your team to review and accept your changes into the main code.

Practice

(1/5)
1. What is the main purpose of Azure Repos in software development?
easy
A. To design user interfaces
B. To store code safely and track changes over time
C. To run applications in the cloud
D. To manage virtual machines

Solution

  1. Step 1: Understand Azure Repos role

    Azure Repos is a service that stores source code and tracks changes made by developers.
  2. Step 2: Compare options with Azure Repos function

    Options A, B, and D describe other Azure services or tasks unrelated to source control.
  3. Final Answer:

    To store code safely and track changes over time -> Option B
  4. Quick Check:

    Azure Repos = Code storage and version tracking [OK]
Hint: Azure Repos is about code storage and history [OK]
Common Mistakes:
  • Confusing Azure Repos with Azure App Services
  • Thinking Azure Repos manages cloud infrastructure
  • Mixing source control with deployment services
2. Which Git command is used to send your local code changes to Azure Repos?
easy
A. git pull
B. git clone
C. git push
D. git branch

Solution

  1. Step 1: Identify command to send changes

    The git push command uploads local commits to the remote repository like Azure Repos.
  2. Step 2: Understand other commands

    git clone copies a repo, git pull fetches and merges changes, git branch manages branches.
  3. Final Answer:

    git push -> Option C
  4. Quick Check:

    Send changes = git push [OK]
Hint: Push means send your changes to the server [OK]
Common Mistakes:
  • Using git clone to send changes
  • Confusing git pull with git push
  • Thinking git branch sends code
3. Given this Git command sequence in Azure Repos:
git clone https://dev.azure.com/org/project/_git/repo
cd repo
git checkout -b feature1
git commit -m "Add feature"
git push -u origin feature1

What is the result?
medium
A. A new branch 'feature1' is created locally and pushed to Azure Repos
B. The main branch is overwritten with feature1 changes
C. The repository is deleted from Azure Repos
D. The commit message is ignored

Solution

  1. Step 1: Analyze branch creation and commit

    git checkout -b feature1 creates and switches to a new branch named 'feature1'. The commit adds changes to this branch.
  2. Step 2: Understand push command effect

    git push -u origin feature1 uploads the new branch and sets it to track the remote branch in Azure Repos.
  3. Final Answer:

    A new branch 'feature1' is created locally and pushed to Azure Repos -> Option A
  4. Quick Check:

    Branch created and pushed = A new branch 'feature1' is created locally and pushed to Azure Repos [OK]
Hint: Checkout -b creates branch; push uploads it [OK]
Common Mistakes:
  • Assuming main branch is overwritten
  • Thinking repository is deleted
  • Ignoring the commit message effect
4. You try to push changes to Azure Repos but get an error about non-fast-forward updates. What should you do to fix this?
medium
A. Run git pull to update your local branch before pushing
B. Delete the remote repository and push again
C. Use git clone again to overwrite your local repo
D. Ignore the error and push with --force immediately

Solution

  1. Step 1: Understand non-fast-forward error

    This error means the remote branch has changes your local branch lacks, so push is rejected to avoid overwriting.
  2. Step 2: Fix by syncing local branch

    Running git pull fetches and merges remote changes into your local branch, resolving conflicts before push.
  3. Final Answer:

    Run git pull to update your local branch before pushing -> Option A
  4. Quick Check:

    Sync local branch first = git pull [OK]
Hint: Pull first to sync before pushing [OK]
Common Mistakes:
  • Forcing push without syncing
  • Deleting remote repo unnecessarily
  • Cloning again instead of pulling
5. Your team uses Azure Repos and wants to protect the main branch from direct changes. Which feature should you enable to require pull requests for all changes?
hard
A. Create a new repository for each developer
B. Enable Git Large File Storage (LFS)
C. Set up Azure Pipelines for continuous deployment
D. Branch policies with pull request requirements

Solution

  1. Step 1: Identify feature to protect main branch

    Branch policies in Azure Repos allow setting rules like requiring pull requests before merging to main.
  2. Step 2: Evaluate other options

    Git LFS manages large files, pipelines automate deployment, and creating repos per developer doesn't protect main branch.
  3. Final Answer:

    Branch policies with pull request requirements -> Option D
  4. Quick Check:

    Protect main branch = branch policies [OK]
Hint: Use branch policies to require pull requests [OK]
Common Mistakes:
  • Confusing deployment pipelines with branch protection
  • Thinking Git LFS controls code changes
  • Creating multiple repos instead of using policies