gittortoisegit

GIT: "fatal: unable to write new_index file" while commit


When I try to commit changes to local repo, I have got following message:
fatal: unable to write new_index file


Solution

  • As this thread illustrates, this is usually a disk space issue:

    $ git status
    fatal: unable to write new_index file
    

    One cause of this that I found was that my file system had run out of space.
    Finding large directories with something like the following helped clean up some log files that had run wild :

    $ du -h / | grep ^[0-9.]*G
    

    Note: you can also see it for

    Problem still remained so I ran File Monitor from Sysinternals Suite.
    It seems that Eclipse is accessing the index file constantly and blocks command line git

    Yeah, looks like Windows Defender strikes again. I always forget to disable that damn thing. I can't believe how broken it is. Destroys Blu-ray playback at home, breaks Git at work...


    Before Git 2.46 (Q3 2024), batch 17, when "git merge"(man) sees that the index cannot be refreshed (e.g., due to another process doing the same in the background), it died but after writing MERGE_HEAD etc. files, which was useless for the purpose to recover from the failure.

    See commit 2e5a636 (17 Jun 2024) by Kyle Zhao (yefengzkk).
    (Merged by Junio C Hamano -- gitster -- in commit 6c0bfce, 27 Jun 2024)

    merge: avoid write merge state when unable to write index

    Signed-off-by: Kyle Zhao

    Writing the merge state after the index write fails is meaningless and could potentially cause Git to lose changes.

    That means, when you encounter that fatal error, you will no longer see any: