Interview Prep/Git & GitHub/Merge and Rebase Problems

After a merge, the same function appears twice in the file.

IntermediateTroubleshootingMerge and Rebase Problems
Answer

Likely causes → Both branches added the same function at different places (no textual conflict), or a resolution kept both sides.

Diagnose →

git diff <merge-sha>^1 <merge-sha> -- file
git log --oneline -S'def calculate_tax' -- file

Fix → Remove the duplicate, run tests and linters, and commit. Check the other branch's version to see which has the newer logic.

Prevent → Run the build and tests on the merge result in CI. Duplicate definitions are often caught by a compiler or linter.

All Git & GitHub questions Roadmap: Git & GitHub

More on Merge and Rebase Problems