Ask HN: How often does Git merge make mistakes?

  • 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.