200-901 Question 31
Single answerYou are collaborating on a Git repository with your team. While merging a feature branch into the main branch, a conflict arises in a file named 'app.py'. After resolving the conflict locally, which sequence of Git commands should you execute to correctly complete the merge process and ensure that the main branch reflects the resolved state?
- A
git add app.py, git commit, git push
- B
git commit -m 'Resolved conflict in app.py', git push
- C
git merge --continue, git push
- D
git add app.py, git merge --continue, git push
Show answer and explanation
Correct answer: A
Explanation
When a merge conflict occurs, you need to manually resolve the conflict in the affected files. After resolving, you must stage the file(s) using 'git add', commit the changes to finalize the resolution, and then push the updated branch to the remote repository. This ensures that all collaborators receive the resolved state in their local repositories.
- A. Correct.
Correct. After resolving the conflict, you need to stage the resolved file using 'git add', commit the resolution, and then push the changes to the remote repository.
- B. Incorrect.
Incorrect. While 'git commit' resolves the conflict locally, you must first stage the resolved file using 'git add' before committing.
- C. Incorrect.
Incorrect. 'git merge --continue' is used in other workflows such as interactive rebases but is not applicable here without staging the changes first.
- D. Incorrect.
Incorrect. While 'git add' is used to stage the resolved file, 'git merge --continue' is not required after resolving a merge conflict manually. Instead, you should commit and push the changes.