AZ-401 source control strategy explained

Updated November 23, 2026

The source control domain is 10-15% of AZ-401, the smallest weight on the exam but one of the most predictable. It asks you to pick a branching strategy, enforce it with policies, configure repositories and recover from Git mistakes, on both Azure DevOps and GitHub. The agentic twist is that pull requests may be written by Copilot, so the rules must hold for agents as well as people.

Branch strategies

The outline lists trunk-based, feature branch, release branch, Git worktree, Git flow and GitHub flow. Pick by delivery model:

StrategyFits whenWatch out for
Trunk-basedFrequent small merges, strong automated tests, feature flagsNeeds fast CI and flags for unfinished work
Feature branchShort-lived work merged by pull requestLong-lived branches drift and conflict
GitHub flowContinuous deployment from mainNo built-in release branches
Git flowScheduled, versioned releasesHeavy; develop and release branches add overhead
Release branchSeveral supported versions or a stabilization periodFixes must be ported between branches
Git worktreeOne person (or agent) needs several branches checked out at onceA local technique, not a team policy

Worktrees matter more in an agentic setup: each agent can work in its own checkout of the repository without disturbing the others.

Pull requests, policies and protection rules

Azure DevOps uses branch policies; GitHub uses branch protection rules (and rulesets). The same controls appear on both sides:

  • Minimum number of reviewers, and no approving your own change.
  • Required status checks or a successful build before merge.
  • Linked work items or issues.
  • Merge restrictions, such as squash only or no force pushes.
  • Code owners as required reviewers for sensitive paths.

The new objective is applying these to GitHub Copilot. The principle: an agent is a contributor, not an administrator. Its pull requests pass the same reviews and checks, and a person is accountable for approving them.

Repositories

  • Permissions: grant by team and role with least privilege, rather than per user.
  • Tags: mark releases; they are the stable reference for what was shipped.
  • Traceability: surface code quality and coverage results on the pull request, and use deep links so a commit leads to its work item or issue.
  • Git hooks: local checks, such as linting or secret detection, that run before a commit or push. They are advisory because a developer can skip them, so pair them with server-side policies for enforcement.
  • Migration: moving a repository from Azure DevOps to GitHub is a repository-to-repository migration, including history; the exam tests that you migrate the Git data and plan separately for pipelines and work items.
  • Recovery: removing or recovering data with Git commands, for example reverting a commit, restoring a deleted branch from reflog, or removing a committed secret from history (and rotating it, since it was exposed).

Common traps

  1. Relying on hooks for enforcement. Hooks live on the client.
  2. Deleting a leaked secret in a new commit. It stays in history; rotate it and rewrite history if needed.
  3. Choosing Git flow for a team that deploys many times a day.
  4. Exempting bots or agents from branch rules for convenience.

Three practice questions

Question 1. A team deploys to production from main many times a day, has strong automated tests and uses feature flags for unfinished work. Which branching strategy fits best?

  • A. Git flow with long-lived develop and release branches
  • B. Trunk-based development with short-lived branches
  • C. A separate long-lived branch per developer
  • D. Release branches only, merged once a quarter
Show answer

Answer: B

Trunk-based development with short-lived branches suits frequent integration backed by tests and flags. Git flow adds long-lived develop and release branches meant for scheduled releases, and keeping a branch per developer for months produces painful merges.

Want more questions like this? Full AZ-401 practice tests →

Question 2. A developer committed an API key to a repository two weeks ago and then removed it in a later commit. What should you do first?

  • A. Revoke and rotate the key, then remove it from history
  • B. Do nothing because the latest commit no longer contains it
  • C. Force-push over main and consider the matter closed
  • D. Ask the developer to promise not to do it again
Show answer

Answer: A

The key is still in history and must be considered compromised, so revoke and rotate it first; cleaning history comes after. Leaving it because the file no longer contains it ignores the history, and a force push alone does not undo exposure through clones or caches.

Want more questions like this? Full AZ-401 practice tests →

Question 3. You want to stop anyone, including an AI agent, from merging unreviewed changes into main on GitHub. Which setting does this?

  • A. A pre-commit hook on each developer machine
  • B. A wiki page that asks people to request reviews
  • C. A branch protection rule requiring reviews and passing checks
  • D. Remove write access for everybody
Show answer

Answer: C

A branch protection rule that requires pull request reviews and status checks applies to every contributor, including agent-authored pull requests. A local pre-commit hook can be skipped, a wiki guideline is not enforced, and removing write access from everyone would stop legitimate work.

Want more questions like this? Full AZ-401 practice tests →

Next: build and release pipelines.