This:
I just noticed, when I git checkout to the otherPersonsBranch, the file in question I get:
error: Your local changes to the following files would be
overwritten by checkout:
xx/xx/fileInQuestion.js
Please commit your changes or stash them before you switch branches
is definitely important. It is possible to run git merge
with uncommitted changes in the work-tree, but I strongly recommend against that. (The main problem is that if the merge goes wrong, it can be very difficult to back out of it. If you have committed everything, it is easy to back out of it.)
In any case, once you do have everything committed, to see what a merge will do, first find the merge base. See, e.g., Find the most recent common ancestor of two Git branches or many of my recent answers. The merge will compare the merge base to each of the two branch tip commits. You can do this same thing yourself, using git diff
—see the special syntax in that same answer, or:
Yesterday, we noticed that there is at least one file where some changes aren't merging.
Git doesn't compare the two branch tips to each other. Running git merge $other
compares the base to your branch tip:
git diff --find-renames $base HEAD # see what we did
and again to their branch tip:
git diff --find-renames $base $other # see what they did
and then combines those two sets of changes. So the chosen merge base is critical to this process, as are the contents of the two tips. (Any commits in between are quite literally irrelevant, except in terms of their role in locating the merge base commit.)
(When you have uncommitted changes, the first git diff
is in effect against your index, rather than your HEAD
commit. Actually, this is always true, it's just that if everything is committed, HEAD
and your index match, by definition. Meanwhile, the low level merge process, which runs after the two diffs have done the appropriate file-matching, attempts to preserve un-indexed work-tree changes as well; this is where things get really messy.)