200-901 Question 27
Single answerYou are working on a CI/CD pipeline to manage a Git repository for your application. The team has decided to integrate automated testing during the pipeline execution. A junior developer pushes changes to the remote repository, but the pipeline breaks when pulling the latest updates during a merge conflict. What Git operation should the developer have performed to ensure their changes are properly integrated without disrupting the pipeline?
- A
Use 'git pull --rebase' to reapply local commits on top of the latest remote changes
- B
Use 'git push' without pulling the latest changes from the remote repository
- C
Use 'git fetch' to download changes and resolve conflicts manually
- D
Use 'git merge --abort' to cancel the merge and retry the operation
Show answer and explanation
Correct answer: A
Explanation
The 'git pull --rebase' command is the most appropriate in this scenario because it integrates the latest remote changes with the local branch by replaying local commits on top of the remote branch. This avoids unnecessary merge commits and helps prevent breaking the CI/CD pipeline due to merge conflicts. Other options either do not address the problem or require additional manual steps, which are less efficient in a CI/CD workflow.
- A. Correct.
'git pull --rebase' ensures that the local commits are reapplied on top of the latest changes from the remote repository, avoiding unnecessary merge commits and reducing the chances of a merge conflict.
- B. Incorrect.
'git push' without pulling the latest changes can cause conflicts if the remote branch has been updated by other team members, disrupting the pipeline.
- C. Incorrect.
'git fetch' only downloads changes from the remote repository but does not integrate them with the local branch, requiring additional manual steps to handle conflicts.
- D. Incorrect.
'git merge --abort' only cancels an ongoing merge operation; it does not resolve the issue of integrating changes or avoiding conflicts in the first place.