Git Rebase vs Merge Before Pull Request
Two developers are working on separate application releases. The developers have created feature branches named Branch A and Branch B by using a GitHub repository’s master branch as the source. The developer for Branch A deployed code to the production system. The code for Branch B will merge into a master branch in the following week’s scheduled application release. Which command should the developer for Branch B run before the developer raises a pull request to the master branch?
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
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.
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.
Community Discussion (5 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
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?
Git pull creates a merge commit, which can clutter the history with non-linear merge nodes. Rebasing moves your commits to the tip of master, keeping history linear.
What is the risk of using git rebase?
Rebasing rewrites commit history. If others have cloned your feature branch, their local copies will diverge, requiring force pushes and causing collaboration issues.
Related Analysis
Practice All DEA-C01 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DEA-C01 Practice Test →