Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git "fatal: .git/index: index file open failed: Permission denied"

So, I have been working on a project and have been using git to push to github, and then suddenly today after I have been working for a little while I went to git add and got fatal: .git/index: index file open failed: Permission denied

I can't think of anything I have done recently on my computer that would cause this. Although I woke up today noticing my computer had rebooted overnight, and I noticed some different settings were not how I normally leave them. For instance quiet mode was turned off, and I always have that on. Thought it was kind of weird but ran a virus scan and didn't notice anything so I shrugged it off thinking it may be something on window's end.

Should I be nervous something is playing with my permissions? After a few minutes of googling I haven't found out too much on this error. Kinda baffled because I haven't personally changed any permissions and it everything seemed fine yesterday.

Looking for some help, if there is anything else I need to include to solve this error I'll gladly provide it if asked. Nobody else uses this computer. It is a Windows 10 build, git version 2.6.3.windows.1.

edit: Here's the output

11:21:34.673917 trace.c:319             setup: git_dir: .git
11:21:34.674417 trace.c:320             setup: git_common_dir: .git
11:21:34.674417 trace.c:321             setup: worktree: D:/Downloads/AnotherTabExample
11:21:34.674417 trace.c:322             setup: cwd: D:/Downloads/AnotherTabExample
11:21:34.674417 trace.c:323             setup: prefix: (null)
11:21:34.674417 git.c:348               trace: built-in: git 'add' '.'
fatal: .git/index: index file open failed: Permission denied
like image 502
Dustin Avatar asked Dec 17 '15 18:12

Dustin


2 Answers

Mark: If you have this error in Android studio, just restart your android studio and this error will be solved. I guess that This is because of some 'cache' or 'bug' of intellij idea.

like image 52
Licat Julius Avatar answered Sep 19 '22 21:09

Licat Julius


From the verbose output, it appears that the permissions of the .git/index while might have gotten corrupted.

Confirm that this is the case by doing a ls -al .git/index followed by a chmod 644 .git/index to fix it. Then try running the git add command again.

Update

It turned out to be a (Windows) permissions issue. What worked was simply creating a copy from within msysgit of the original folder and using that (i.e. cp -rvf original original-bkup).

A reset of the permissions on the original folder should have worked, but didn't.

like image 7
Ashutosh Jindal Avatar answered Sep 22 '22 21:09

Ashutosh Jindal