During a merge you want your version of one file wholesale and theirs for another. How?
IntermediateScenarioBranching and Merging Workflows
Answer
Situation read → Per-file decisions during a conflicted merge.
What I'd do →
- Take our side for the file:
git checkout --ours config/prod.yaml. - Take their side for another:
git checkout --theirs docs/guide.md. - Stage both, then finish the merge.
git checkout --ours config/prod.yaml
git checkout --theirs docs/guide.md
git add config/prod.yaml docs/guide.md
git merge --continue
Why → In a merge, "ours" is the branch you are on and "theirs" is the one being merged. In a rebase these are swapped.
Interview tip → Distinguish this from -X theirs, which only auto-wins on conflicting hunks while still merging the non-conflicting ones.
More on Branching and Merging Workflows
You run `git pull` and Git stops with a merge conflict in `app.py`. What do you do?BeginnerYour 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?Beginner