โ† Git, Tools & AI
#4 most askedVery commonEasyBranching & PRs

Resolving a merge conflict

New to Branching & PRs? Learn it from scratch first
Branches, Pull Requests & Code Review โ†’
๐Ÿข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.
I was asked this

You pull and Git reports a conflict in pricing.ts. Walk through resolving it safely.

๐ŸŽค Answer it out loud, then check yourself

Say your answer as if the interviewer is listening (30โ€“90 seconds). Then reveal what a strong answer covers and tick what you said.

    Try it ยท run and change it
    const conflicted = [
      "<<<<<<< HEAD",
      "const MONTHLY = 5;",
      "=======",
      "const MONTHLY = 6;",
      "const YEARLY = 39;",
      ">>>>>>> main",
    ].join("\n");
    const ours = conflicted.split("=======")[0].split("\n").slice(1).join("\n");
    const theirs = conflicted.split("=======")[1].split(">>>>>>>")[0].trim();
    console.log("OURS:\n" + ours.trim() + "\n\nTHEIRS:\n" + theirs);
    console.log("\nResolved (decided with the team): const MONTHLY = 5; const YEARLY = 39;");
    
    Answer out loud first, then compare.
    Want to rehearse it?
    Answer this to the AI interviewer and get a verdict โ†’