What is a merge conflict and how do you resolve it?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Git & GitHub basics — a prerequisite for any developer role.
Answer
A merge conflict occurs when Git can't automatically merge changes because two branches modified the same part of the same file in different ways. Git doesn't know which version to keep, so it marks the conflict in the file for you to resolve manually. Conflict markers in the file: <<<<<<< HEAD (current branch changes), ======= (separator), >>>>>>> feature-branch (incoming changes). Resolution steps: (1) Run git status to see all conflicted files ("both modified"); (2) Open each conflicted file; (3) Find the conflict markers; (4) Edit the file to keep the correct content (either/both/neither version); (5) Remove ALL conflict markers (<<<<<<<, =======, >>>>>>>); (6) git add the resolved files; (7) git commit to complete the merge. Abort a conflicted merge: git merge --abort. Visual merge tools: git mergetool opens a configured tool (VS Code, vimdiff, IntelliJ). VS Code has excellent built-in conflict resolution UI. Prevention: pull frequently, keep branches short-lived, communicate with teammates about which files you're modifying.
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last Git & GitHub project, I used this when...' immediately makes your answer more credible and memorable.