300-435 Question 8
Select 3A network automation engineer is working on a Git repository for a Cisco Enterprise automation project. The engineer has made changes to multiple files and wants to upload these changes to the remote repository. However, upon attempting to push the changes, a merge conflict occurs. What actions should the engineer take to resolve the merge conflict and successfully push their changes?
- A
Use 'git diff' to inspect the conflicting changes and identify the differences.
- B
Use 'git clone' to re-download the repository and overwrite the local changes.
- C
Manually edit the conflicted files to resolve the conflicts, then mark them as resolved using 'git add'.
- D
Use 'git push --force' to overwrite the changes in the remote repository.
- E
Commit the resolved changes locally and then push again to the remote repository.
Show answer and explanation
Correct answers: A, C, E
Explanation
When a merge conflict occurs in Git, the engineer must first identify the conflicting changes using tools such as 'git diff'. They must then manually resolve the conflicts in the affected files and mark them as resolved using 'git add'. Once the conflicts are resolved, the resolved changes need to be committed locally. Finally, the engineer can push the changes to the remote repository. This process ensures that the integrity of the repository and collaboration is maintained.
- A. Correct.
Correct: 'git diff' helps identify the differences in the conflicting files, making it easier to resolve the conflict.
- B. Incorrect.
Incorrect: Re-cloning the repository will overwrite the local changes and does not resolve the conflict. This is not a proper way to handle merge conflicts.
- C. Correct.
Correct: Manually resolving the conflicts in the files and marking them as resolved using 'git add' is necessary to proceed.
- D. Incorrect.
Incorrect: Using 'git push --force' will overwrite the remote changes, which is not recommended in collaboration scenarios as it may cause data loss.
- E. Correct.
Correct: After resolving the conflicts and staging the changes, committing them locally and pushing again is the correct procedure.