Pulling the Latest Main and Rebasing Before Opening a Pull Request
Network Topology
Refer to the exhibit. A developer is on the 'feature/login' branch and wants to integrate the latest changes from 'feature/user-profile' without creating a merge commit. Which Git command should the developer use?
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
✓
git rebase origin/feature/user-profile
To integrate changes from another branch without a merge commit, rebase is appropriate. The developer can rebase feature/login onto feature/user-profile (or onto main after merging user-profile). However, the exhibit shows that feature/user-profile is already merged into main, so rebasing feature/login onto main is also valid. The simplest is to rebase feature/login onto main, but that would include all changes. Alternatively, rebasing feature/login onto feature/user-profile directly would also work, but since user-profile is merged into main, rebasing onto main is common. The correct answer is rebase.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
git rebase origin/feature/user-profile
Why this is correct
git rebase origin/feature/user-profile is correct because it replays the unique commits from the current feature/login branch on top of the latest commits from origin/feature/user-profile, creating a linear history without a merge commit while preserving the login-specific changes.
- ✗
git pull --rebase origin main
Why it's wrong here
git pull --rebase origin main is wrong because it fetches and rebases the current branch onto the main branch, not onto feature/user-profile, which would incorrectly integrate changes from the trunk instead of the intended feature branch.
- ✗
git merge origin/feature/user-profile
Why it's wrong here
Running `git merge origin/feature/user-profile` would successfully combine the two branches, but it creates a merge commit with two parents, permanently recording the divergent histories of `feature/login` and `origin/feature/user-profile`. That produces a non-linear commit graph with an extra merge commit, which is exactly the kind of history the team wants to avoid when integrating an in-progress feature branch. It also makes a later `git rebase` onto `main` more difficult because the merge commit cannot be replayed cleanly by rebase.
- ✗
git cherry-pick 9f8e7d6..8a7b6c5
Why it's wrong here
`git cherry-pick 9f8e7d6..8a7b6c5` only reapplies the individual commits contained in that range as new commits on top of `feature/login`; it does not move `feature/login` to match `origin/feature/user-profile` or bring over the branch's full state. This is not the standard way to integrate an entire feature branch, and it leaves `origin/feature/user-profile` untouched, so a subsequent `git merge` or `git rebase` will try to reapply the same changes, causing duplicate commits or conflicts. Additionally, the hard-coded SHA range is brittle and easy to get wrong when new commits are added upstream.
Go deeper
Related to this question
Learn chapter
Implementing Work Item Management and Agile Planning
Key term
Branch
A branch is a pointer to a specific commit in a version control system that allows you to work on features or fixes in isolation from the main codebase.
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.
About these practice questions
Courseiva writes every AZ-400 question from scratch — 696 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 →
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.