One developer renamed `utils.py` to `helpers.py` while another edited `utils.py`. Will merge handle it?
IntermediateScenarioBranching and Merging Workflows
Answer
Situation read → Git does not store renames; it detects them by similarity when merging.
What I'd do →
- Merge normally. With the default
ortstrategy, rename detection usually applies the edit tohelpers.py. - Check:
git statusandgit diff --name-status -M main...feature. - If similarity is too low (heavily edited file), you get a "rename/delete" conflict. Resolve by hand and keep the new name.
- Tune detection if needed:
git merge -X find-renames=40%.
Why → Rename detection is content-similarity based, default threshold 50%.
Interview tip → Advise doing renames in their own commit, with no content edits, so Git can track them.
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