300-435 Question 5
Select 3A network automation engineer is working on a Git repository for a Cisco enterprise solution project. They need to add a new feature and collaborate with other team members. The engineer creates a new branch, makes several changes to the code, and commits the changes. When attempting to merge the branch into the main branch, a merge conflict arises. What steps should the engineer take to resolve the conflict and complete the merge?
- A
Identify the conflicting files and manually resolve the differences.
- B
Use the 'git merge --force' command to override the conflict and complete the merge.
- C
Stage the resolved files and create a new commit to finalize the merge.
- D
Delete the branch with the conflict and create a new branch to start over.
- E
Use the 'git diff' command to inspect the changes causing the conflict.
Show answer and explanation
Correct answers: A, C, E
Explanation
To resolve a merge conflict in Git, the engineer must identify and manually resolve the conflicts in the affected files. This can be done by using tools like 'git diff' to inspect the changes. Once resolved, the engineer must stage the resolved files and commit them to complete the merge process. Overriding or deleting branches is not a recommended practice, as it could result in loss of work or additional complications.
- A. Correct.
Correct. When a merge conflict occurs, the engineer must identify the conflicting files and manually resolve the differences in the code.
- B. Incorrect.
Incorrect. The 'git merge --force' command does not exist and forcefully overriding conflicts is not a standard or safe practice in Git.
- C. Correct.
Correct. After resolving the conflicts, the engineer needs to stage the resolved files and create a new commit to finalize the merge.
- D. Incorrect.
Incorrect. Deleting the branch is unnecessary and counterproductive. The engineer can resolve conflicts without discarding the branch.
- E. Correct.
Correct. The 'git diff' command helps inspect the changes and identify the root cause of the conflict, which aids in resolving it.