Search code examples
gitunison

Why does `.git/index` change when I haven't done anything to my repository?


With the latest Debian version of git (I'm using 1.7.2.5), I've noticed that a .git/index file may change mysteriously, without my having performed any operation that I feel should change the repository. (My shell occasionally runs git branch so it can display what branch is checked out, but that shouldn't change anything.) The change results in a .git/index file with the same length as the original, but containing different bits. What causes this change, and how can I stop it?

(The change is inconvenient because it messes things up for the Unison file synchronizer.)


Solution

  • The culprit turned out to be Emacs VC mode: https://emacs.stackexchange.com/questions/38418/could-magit-be-writing-git-index-without-my-intervention

    In order to make this text an answer, not a comment, I have to say more. So the correct answer is reproduced here:

    Emacs VC uses timers to periodically refresh some information and calls git commands to do so and some of those touch the index.

    Provided VC was the cause of this issue, then deleting Git from vc-handled-backends would likely fix it.