Git 'fatal: unable to write new index file'

I have seen many other topics about this, and they do not help.

I have a very simple repo - two JavaScript files. I have 100 + GB on a Macbook. When I try to move files to a subdirectory and put locally the changes that I get ...

fatal: unable to write new index file

This happens regardless of whether I perform all the actions in the terminal or use a graphical interface such as SourceTree. In addition, one of the files becomes locked, and I can’t delete the working directory until I log out and return.

Why is this happening? Is blocking something obstructive? If so, what / how to unlock the problem file on OS X ?? Remote repo is Google Code, if that matters, although I don’t click on the remote computer yet. Everything is local.

+98
git locking
Apr 17 '13 at 15:44
source share
22 answers

In my case, the disk ran out of free space, so I had to delete the files from the hard drive to free up space.

+158
Jan 16 '15 at
source share

I had the same problem in the last few days. In principle, without my knowledge, the entire repo was moved to the new file system, when I tried to run the git status, it was suddenly reported that every file in the repo was reset to zero.

Possible solutions

So, after cleaning Google multiple times, I tried the following:

  • changing .git permssions (same problem)
  • changing .git / index permissions (same problem)
  • git adding all changes to commit (same problem)
  • git rm-ing deleted files since they reported too long file errors (same problem)
  • git reset (soft | Head | Hard) (same problem)
  • git clean (same problem)
  • disable windows defender (same problem)
  • git update (same issue)
  • different git clients (I use gitbash) (same problem)
  • drink 2 coffee instead of 1 (same problem)

tl: dr - dirty solution

The only thing that managed to solve the problem was to copy the index file, delete the original and rename the copy.

I know that this is not a “solution”, but now its magically working> <, with all files / branches. If anyone knows why this might have a job, tell me.

+57
Mar 12 '14 at 4:09
source share

I had the same issue on a Mac. This seems to be caused by the file system ACL. Try chmod -RN /path/to/repo clear ACLs. By doing this, I was able to make changes. Using the trick to copy the index file, delete the original and move the copy back to get the same result.

+15
Sep 19 '15 at 2:31
source share

If you have github configured in some online synchronization service, for example, on google drive or dropbox, try disabling synchronization because the synchronization service is trying to read / write a file, as github is trying to do the same, which leads to github not working. right.

+14
Apr 30 '17 at 12:58
source share

In my case, pausing Dropbox sync solved the problem

+11
Mar 04 '17 at 2:47 on
source share

It happened to me that the .git / index file was used by another process (my local development web server). I closed the process and then it worked.

+7
Mar 27 '15 at 15:36
source share

This worked for me:

 rm -f ./.git/index.lock 
+6
Feb 11 '18 at 14:45
source share

In my case, the solution was to only add permission to the new user.

When I installed the new OS, moved my repositories, and it showed exactly this error, I selected the root folder and then added an authenticated user to check everything enter image description here

+4
Mar 26 '19 at 13:27
source share

I had an ACL (somehow) attached to all the files in the .git folder.

Check it with ls -le in the .git folder.

You can remove the ACL with chmod -N (for folder / file) or chmod -RN (recursive)

+3
02 Feb '16 at 13:50
source share

I think some background backup solutions, such as Google Backup and Sync, block access to the index file. I closed the application and Sourcetree had no problems. Dropbox seems to do the same (@tonymayoral).

+3
Jul 05 '18 at 13:25
source share

In my case, it was running EGit at the same time. After restarting eclipse, it works as usual.

+2
Feb 25 '15 at 14:27
source share

If you are in a Windows window, make sure that the program you are using, whether it is the source tree or the git terminal, works as an administrator. I was getting the exact same error message. You can right-click on a program so that it can be run as an administrator or change its properties so that it always starts as an administrator.

+2
Jul 28 '16 at 21:22
source share

Closing the Visual Studio code (in my case there is a background startup work performed when the file was saved) solved the problem for me.

Credit for the decision: my friend and colleague Arnel.

+2
Dec 18 '17 at 15:31
source share

You tried 'git add.', Will there be any changes? (you can delete unnecessary added files with git reset HEAD)

+1
Jan 16 '14 at 5:29
source share

Lack of space is a problem. Clean and try again

+1
Jun 02 '17 at 4:24
source share

This problem may be caused by .git\index blocked by the process.

Link Find out which process locks a file or folder in Windows determines the following approach for finding a locked file:

SysInternals Process Explorer - Choose Find> Find Descriptor or DLL. In the text box "Handle or DLL substring:" enter the path to the file (for example, "C: \ path \ to \ file.txt") and click "Search". All processes that have an open handle to this file should be listed.

Use the approach described above to determine which process is blocked by .git\index , and then stop the executable file of the lock. This should solve the problem.

For example, Process Explorer Search shows that my .git\index was blocked by vmware-vmx.exe . Suspending the VMWare player virtual machine (accessing the repo via git through a shared folder) solved the problem.

+1
Jun 13 '17 at 18:37
source share

I have the same problem. I rebooted the computer and the problem was resolved.

+1
Aug 21 '19 at 19:48
source share

IF YOU RECEIVE THIS DURING REBESS:

This is most likely due to some software blocking your repo index file, such as backup software, antiviruses, IDEs, or other git clients.

In most cases, the lock is only performed for a short moment, and therefore it simply happens due to bad time and failure.

However, git rebase --continue will complain about the following command, which is an empty commit:

 The previous cherry-pick is now empty, possibly due to conflict resolution. If you wish to commit it anyway, use: git commit --allow-empty 

To fix this, just run git reset and try git rebase --continue .

0
Nov 16 '16 at 1:43
source share

Problem: when I checked some modified files in git, I got this error. I had two users ABC and XYZ. Files have uid: gid from ABC, but it does not have access to git, and they try to extract files with the same name.

Solution I tried: XYZ has access to git, tried to check files with sudo, and it worked .. !!

0
Jan 08
source share

Here is what worked for me:

Context:

  1. Build the project on the server

  2. git status returns HEAD detached at <commit-SHA>

  3. Whatever operation I did locally, I had this error. More specific:

    • Git checkout
    • git reset HEAD --hard

Decision

  1. Just deleted the file <work-dir>/.git/index .
  2. The git status will mean that all files in the project are not monitored (there is nothing surprising here).
  3. git reset HEAD --hard
  4. Back to HEAD detached at <commit-SHA> when git status executed, but then you can
  5. git checkout <some-branch>

and you are back on the track!

!! IMPORTANT !!

This only works because I am a "fun" system. No precious changes were made to the code. If you are actually in “development time,” I would recommend first saving your work or switching to another method.

Hope this helps :).

0
Jan 18 '18 at 10:30
source share

I had this problem using GitExtensions on Windows. Fixed by providing full permission for the current user (me) to the folder containing the repo.

Another time, despite the fact that I was getting an error from Git Extensions, I was able to commit the same files from Visual Studio 2015.

Another time I had to delete the "index" file from the .git folder

0
Mar 15 '18 at 10:38
source share

My case is a little interesting:

I run git log to check for a specific commit, then I did not exit it properly, I press Ctrl + C to exit it.

Then the index seems to have been locked. So I run git log again, then press Q to exit it.

The problem is fixed. :)

0
Jun 27 '18 at 5:19
source share



All Articles