Cleaning Up Feature Branches Automatically with a Branch Policy Setting
A team uses Azure Repos with a Git branching strategy that includes feature branches. They want to ensure that all feature branches are deleted automatically after the pull request is completed. What should they do?
Quick Answer
Enabling 'Automatically delete source branch' in the branch policy is the built-in Azure Repos setting for this — once a pull request completes (merged or abandoned), the source feature branch is deleted automatically, with no manual cleanup step required from anyone on the team.
⚠ Common exam trap
Many exam-takers confuse pipeline retention policies (which manage build artifacts) with Git branch management, or assume that a manual work item is sufficient for automation, when Azure Repos provides a direct built-in setting for automatic branch deletion.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Enable 'Automatically delete source branch' in the branch policy.
Azure Repos branch policies include an 'Automatically delete source branch' checkbox. When enabled, the source branch (e.g., a feature branch) is automatically deleted once the pull request is completed (merged or abandoned). This enforces cleanup without manual intervention, directly meeting the requirement.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Enable 'Automatically delete source branch' in the branch policy.
Why this is correct
This deletes the source branch after the PR is completed.
- ✗
Enable 'Create a merge commit' option in the branch policy.
Why it's wrong here
This option changes merge strategy, not branch deletion.
- ✗
Configure branch retention policy in the pipeline to delete branches after build.
Why it's wrong here
Retention policies delete old runs, not branches.
- ✗
Create a work item to remind developers to delete branches after merge.
Why it's wrong here
This is not automated enforcement.
Go deeper
Related to this question
Learn chapter
Introduction to DevOps and Azure DevOps
Key term
Git
Git is a version control system that tracks changes to files so multiple people can work on the same project without overwriting each other's work.
Key term
Azure Repos
Azure Repos is a set of version control tools that allow teams to manage their source code, track changes, and collaborate on software projects using Git or Team Foundation Version Control (TFVC) within the Microsoft Azure ecosystem.
About these practice questions
Courseiva writes every AZ-400 question from scratch — 823 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on AZ-400
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Your team uses GitFlow and wants to enforce that all feature branches are deleted after merging to develop. Which automation should you implement?
easy- ✓ A.Enable the 'Automatically delete source branches' policy in the branch policy.
- B.Use a post-merge script in the pipeline.
- C.Train developers to delete branches manually.
- D.Configure branch retention policies in Azure Repos.
Why A: The 'Automatically delete source branches' policy in Azure Repos branch policies automatically removes a feature branch once its pull request is completed into the target branch (e.g., develop). This directly enforces the GitFlow requirement without manual intervention or pipeline scripting, as it is a native repository-level setting.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.