Creating a New Branch from an Existing Pull Request - AZ-400 Exam: Microsoft DevOps Solutions

Creating a New Branch from an Existing Pull Request

Question

Your company uses Azure DevOps to manage the build and release processes for applications.

You use a Git repository for applications source control.

You plan to create a new branch from an existing pull request. Later, you plan to merge the new branch and the target branch of the pull request.

You need to use a pull request action to create the new branch. The solution must ensure that the branch uses only a portion of the code in the pull request.

Which pull request action should you use?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

C

Cherry-pick a pull request -

To copy changes made in a pull request to another branch in your repo, follow these steps:

1. In a completed pull request, select Cherry-pick, or for an active pull request, select Cherry-pick from the ... menu. Cherry-picking a pull request in this way creates a new branch with the copied changes. Merge into a target branch in a second pull request.

2. In Target branch, enter the branch you want to merge the copied changes.

3. In Topic branch name, enter a new branch to contain the copied changes, then select Cherry-pick.

4. Select Create pull request to merge the topic branch into the target branch to complete the cherry-pick.

https://docs.microsoft.com/en-us/azure/devops/repos/git/pull-requests

The pull request action that should be used to create a new branch while ensuring that it uses only a portion of the code in the pull request is Cherry-pick.

Cherry-picking is the act of choosing and applying only specific commits from one branch to another. In the context of Git, a commit is a set of changes to the source code. When you cherry-pick a commit, you are selecting those changes and applying them to a different branch. This allows you to extract specific changes from one branch and apply them to another, without having to merge the entire branch.

In this scenario, creating a new branch from an existing pull request means that you want to extract a specific set of changes from the pull request and apply them to a new branch. Cherry-picking allows you to do this by selecting the specific commits that contain the changes you want to include in the new branch.

Setting a branch as the default branch would not create a new branch or select specific changes from a pull request. Approve with suggestions, reactivate, and revert are all actions that relate to the management of pull requests but are not applicable to this specific scenario.