How do you resolve a merge conflict in Git?

Prepare for the TJR Bootcamp Test with quizzes and flashcards. Each question includes hints and explanations to boost your readiness for the exam!

Multiple Choice

How do you resolve a merge conflict in Git?

Explanation:
When a merge conflict happens, Git can’t automatically decide which changes to keep in the files that were edited differently on the two branches. The way to resolve it is to edit those files yourself, decide what the final content should be, and then finalize the merge. Open the conflicting files and look at the sections marked by Git (the conflict markers). Decide which changes to keep, or craft a combined version that integrates both sides as needed. Remove the conflict markers after you’ve made the choice, save the file, and stage the resolved version with git add. Finally, commit to complete the merge so the history records the resolution. This approach directly fixes the content and records your chosen outcome. Deleting the conflicting branch or ignoring the conflict won’t actually resolve what to keep in the files, and reverting the merge undoes the merge rather than providing a resolved integration.

When a merge conflict happens, Git can’t automatically decide which changes to keep in the files that were edited differently on the two branches. The way to resolve it is to edit those files yourself, decide what the final content should be, and then finalize the merge.

Open the conflicting files and look at the sections marked by Git (the conflict markers). Decide which changes to keep, or craft a combined version that integrates both sides as needed. Remove the conflict markers after you’ve made the choice, save the file, and stage the resolved version with git add. Finally, commit to complete the merge so the history records the resolution.

This approach directly fixes the content and records your chosen outcome. Deleting the conflicting branch or ignoring the conflict won’t actually resolve what to keep in the files, and reverting the merge undoes the merge rather than providing a resolved integration.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy