You run `git pull` and Git stops with a merge conflict in `app.py`. What do you do?
BeginnerScenarioBranching and Merging Workflows
Answer
Situation read → Both you and a teammate changed the same lines. Git paused the merge and marked the file with conflict markers.
What I'd do →
git statusto see the "both modified" files.- Open the file, find
<<<<<<<,=======,>>>>>>>, and decide what the final code should be. Talk to the author if the intent is unclear. - Remove the markers, then
git add app.py. - Run the tests, then
git commit(orgit merge --continue).
git status
git add app.py
git merge --continue
Why → Git only knows both sides changed the same hunk, not which one is right. A human has to pick, and tests prove the result.
Interview tip → Say you run tests before finishing the merge, not after.
More on Branching and Merging Workflows
Your feature branch is three weeks old and `main` has moved a lot. Merge `main` in, or rebase onto it?IntermediateThe team argues about fast-forward merges versus merge commits on `main`. How do you settle it?BeginnerA teammate branched from the wrong base, and their PR shows 40 unrelated commits. How do you fix it?IntermediateBefore merging, you want to see exactly what the feature branch adds compared to `main`. Which commands?BeginnerHalfway through a merge you realise you pulled the wrong branch. How do you back out?BeginnerYou keep resolving the same conflicts again and again while rebasing a long-lived branch. How do you stop?Intermediate