by gknoy on 7/11/2015, 7:20:15 PM
I've never noticed that before, but it's possible that you both had added functions in different places:
foo() ... ; original
bar() ... ; added by alice
foo() ...
foo() ...
bar() ... ; added by bob
I haven't tried it, but I could imagine that being seen as separate text additions, and ending up with duplicates if git thinks it needs to merge them: bar() ... ; alice
foo() ... ; original
bar() ... ; bob
You mentioned using `git pull`, which will actually merge things if it thinks it's necessary -- which can lead to tree differences. In practice, I've found it helpful to NEVER USE `git pull`. Rather, I advise using: git checkout master
git fetch origin
git merge origin/master --ff-only
This will ensure that git only does "fast-forward" merges, and does not end up accidentally merging things - and keeps 'origin' as the system-of-record for what's been merged.
I was working on an express app with a friend and git auto merged a file after I ran 'git pull'. There were no merge conflicts, but git added duplicate functions to a file after merge. I spent an hour trying to figure our what the problem was before realizing that git had made a mistake while merging.
I had never seen such a thing before. How often does something like this happen?