Pulling the Latest Main and Rebasing Before Opening a Pull Request
Network Topology
Refer to the exhibit. A developer is working on the feature/login branch and wants to ensure that the latest changes from main are incorporated before creating a pull request. Which command should the developer run next?
Quick Answer
Running git pull --rebase origin main fetches the latest commits on main and replays the feature branch's own commits on top of them — incorporating the newest changes while keeping history linear, which is exactly what's needed before opening a pull request when main has moved ahead since the last sync.
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 pull --rebase origin main
The exhibit shows that the feature/login branch has a merge commit from main (3a1b2c3) which means main was already merged into feature/login. However, the local branch is ahead of origin by 1 commit (the merge commit). The developer wants to incorporate the latest changes from main. Since main has advanced (d4e5f6a is the latest on origin/main), the developer should pull the latest main and rebase or merge again. The best practice is to rebase onto the latest main to maintain a linear history. Therefore, the developer should run 'git pull --rebase origin main' to fetch and 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 --abort
Why it's wrong here
There is no rebase in progress; this command would be invalid.
- ✗
git merge main
Why it's wrong here
While this would merge main again, it would create an extra merge commit. The developer already has a merge from main, but main has advanced. Rebasing is cleaner.
- ✗
git push origin feature/login
Why it's wrong here
Pushing will not incorporate the latest main changes; it will just push the current state.
- ✓
git pull --rebase origin main
Why this is correct
This fetches the latest main and rebases the feature branch onto it, incorporating the latest changes and keeping history linear.
Go deeper
Related to this question
Learn chapter
Final Review and Exam Preparation
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
Feature
A feature is a distinct unit of functionality that delivers value to the user, often managed and tracked throughout the software development lifecycle.
About these practice questions
This AZ-400 question is part of Courseiva's 823-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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. 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?
medium- ✓ A.git rebase origin/feature/user-profile
- B.git pull --rebase origin main
- C.git merge origin/feature/user-profile
- D.git cherry-pick 9f8e7d6..8a7b6c5
Why A: 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.
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.