Git & GitHub
/Intermediate
Conflict Resolution
Definition
The manual process of inspecting a conflicted file, choosing the correct code, removing Git's conflict markers, and finalizing the merge.
Explain Like I'm New
When Git pauses a merge because of a conflict, you open VS Code. VS Code will highlight the conflicts brightly. You click 'Accept Current', 'Accept Incoming', or 'Accept Both'. Once you fix all the files, you tell Git 'I fixed it' by committing.
Real World Example
Getting on a Zoom call with your coworker to decide whose code should be kept and whose should be deleted during a nasty conflict.
Common Use Cases
- •Unblocking a paused merge
Terminal Output
bash / terminal
# 1. You type git merge, and get a CONFLICT error.
$ git merge feature-branch
# CONFLICT (content): Merge conflict in index.html
# Automatic merge failed; fix conflicts and then commit the result.
# 2. Open index.html in your editor and manually fix the text.
# 3. Tell Git the file is fixed by adding it to the staging area.
$ git add index.html
# 4. Finalize the merge by committing!
$ git commit -m "Merge feature-branch and resolve conflict in index.html"
# PANIC BUTTON: If everything is ruined and you want to cancel the merge:
$ git merge --abort
Interview Questions
basic
- How do you tell Git that you have successfully resolved a conflict in a file?
intermediate
- How can you abort a merge completely if the conflicts are too overwhelming?