300-435 Question 6
Select 3You are working on a team project and have cloned the repository to your local machine. After making changes to a file named config.yaml, you attempt to push your changes but encounter a conflict because a teammate has also updated the same file. Which of the following steps must you take to resolve the conflict and successfully push your changes?
- A
Pull the latest changes from the remote repository to your local branch.
- B
Manually resolve the conflict in the
config.yamlfile and mark it as resolved. - C
Commit your local changes before pulling the latest changes from the remote branch.
- D
Push your unresolved changes directly to the remote repository.
- E
Stage the resolved
config.yamlfile and commit the changes.
Show answer and explanation
Correct answers: A, B, E
Explanation
When a conflict occurs in Git due to changes in the same file by multiple contributors, you must first pull the latest changes to your local branch. Then, manually resolve the conflicts in the affected files. After resolving the conflict, the file must be staged and committed before you can successfully push the changes to the remote repository. This ensures the repository remains consistent and conflict-free.
- A. Correct.
Pulling the latest changes ensures your local branch is updated with the remote changes and is necessary for resolving conflicts.
- B. Correct.
Conflicts must be manually resolved in the affected file before proceeding, as Git cannot automatically resolve such issues.
- C. Incorrect.
You should not commit your changes before pulling the latest updates because doing so can create further conflicts.
- D. Incorrect.
Unresolved changes cannot be pushed to the remote repository. Git requires all conflicts to be resolved and committed first.
- E. Correct.
Once conflicts are resolved, the resolved file must be staged and committed to finalize the changes before pushing them.