Git Rebase vs Merge Before Pull Request
Short answer
C The developer should run git rebase master to integrate the latest changes from the master branch into Branch B, ensuring a linear history and minimizing future merge conflicts.
Question
Key Takeaways
The core concept tested is branch synchronization strategy; the common trap is confusing 'git pull' with 'git rebase' or misunderstanding how each affects commit history and conflict resolution.
This question tests best practices for integrating feature branches into a shared master branch using Git. The correct approach is to rebase the feature branch onto the latest master to ensure a clean, linear history before submitting a pull request.
Common mistake: Many learners choose B (git pull master) because it is the standard way to update a local branch with remote changes. However, 'git pull' creates a merge commit, which can clutter the project history with unnecessary merge nodes, whereas rebasing keeps the history linear.
Expert Analysis
Why the Answer Is Correct
Rebasing Branch B onto the updated master branch ensures that Branch B incorporates all the recent changes from the master branch (including the changes from Branch A that were deployed to production). It helps maintain a linear, clean history by placing Branch B's commits on top of the latest master branch commits. This approach reduces the likelihood of merge conflicts later during the actual pull request review and results in a more readable project history.
Why the Other Options Are Wrong
Option A (git diff) only shows differences but does not apply them, leaving the branch outdated. Option B (git pull master) performs a fetch followed by a merge, which creates a new merge commit object. While safe, this often leads to a non-linear history with many merge bubbles, which is generally discouraged for feature branches intended for clean integration. Option D (git fetch -b master) is syntactically incorrect; 'git fetch' does not take a '-b' flag to specify a branch name in this manner.
Community Comment Notes
Community consensus strongly favors C, with most users noting that rebasing provides a cleaner history. One user noted that rebasing places commits on top of the latest master, reducing conflicts. Another user highlighted that while merging is a default option, rebasing is preferred for maintaining a linear timeline in feature branches.
Exam Strategy
When integrating feature branches, prefer rebasing over merging if you want a linear history and are sure no one else is working on your feature branch. Always rebase against the latest master to catch any potential conflicts early, before raising a pull request.
Frequently Asked Questions
Why not use git pull instead of git rebase?
What is the risk of using git rebase?
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 5 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 5
-
AgboolaKun 👍 4 Answered CThe correct answer is C. Here is why: Rebasing Branch B onto the updated master branch ensures that Branch B incorporates all the recent changes from the master branch (including the changes from Branch A that were deployed to production). It helps maintain a linear, clean history by placing Branch B's commits on top of the latest master branch commits. This approach reduces the likelihood of merge conflicts when the pull request is eventually merged into master. It makes the code review process easier as all the changes in the pull request will be relevant and up-to-date. By using git rebase master, the developer ensures that Branch B is up-to-date with all changes in the master branch, including those from Branch A, before creating the pull request. This approach helps maintain a clean, linear history and reduces the likelihood of conflicts during the merge process.
-
mzansikiller 👍 3Rebasing In Git, there are two main ways to integrate changes from one branch into another: the merge and the rebase. In this section you’ll learn what rebasing is, how to do it, why it’s a pretty amazing tool, and in what cases you won’t want to use it. The Basic Rebase If you go back to an earlier example from Basic Merging, you can see that you diverged your work and made commits on two different branches. Answer C
-
simon2133 👍 1 Answered BB It's considered the general default option for a few reasons (1) it includes git fetch and (2) you won't get a merge conflict if there happens to be a branch C spawned off after A was merged, you won't need to use --force (3) related to (2) you're less likely to be clobbering commit history
-
matt200 👍 2 Answered COption C: git rebase maste
-
aragon_saa 👍 2 Answered CAnswer is C
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All DEA-C01 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DEA-C01 Practice Test →