Search code examples
gitgit-merge-conflict

What happens if I pull a change on a file earlier set assume-unchanged in Git?


I'm curious if I run git update-index --assume-unchanged, and somebody chages that file in a way that produces a conflict, what happens, if I pull those changes? Do I get a simple conflict? Does it overwrite my changes, since it assumes the file is not changed?


Solution

  • This is fairly easy to test. With Git 1.9.1 on my Linux machine, Git detects that such changes would be lost and prevents that from happening:

    $ git pull
    remote: Counting objects: 5, done.
    remote: Total 3 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (3/3), done.
    From file:///XXXXXXX
       493134f..d04cb06  master     -> origin/master
    Updating 493134f..d04cb06
    error: Your local changes to the following files would be overwritten by merge:
            foo.bar
    Please, commit your changes or stash them before you can merge.
    Aborting
    

    As a side note, I recommend avoiding git update-index if you can, as it was not designed with end users in mind.