Git "fatal: .git / index: could not open index file: permission denied"

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

I can not think of anything that I did recently on my computer that could cause this. Although I woke up today, noticing that my computer rebooted overnight, and I noticed that some of the different settings were not the same as I usually leave them. For example, silent mode is disabled, and I always have this. I thought it was strange, but I checked for viruses and didn’t notice anything, so I shrugged, thinking that it could be something at the end of the window.

Should I be nervous, something is playing with my permissions? After a few minutes of searching on Google, I did not learn too much about this error. A kind of bewilderment, because I personally did not change any rights, and yesterday everything looked good.

Seek some help if there is anything else that I need to enable to solve this error, I will gladly provide it if you are asked. No one is using this computer. This is a build of Windows 10, git version 2.6.3.windows.1 .

edit: Here is 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 
+12
git windows github
source share
3 answers

From the detailed output it can be seen that the .git/index permissions while may have been corrupted.

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

Update

It turned out that this is a problem with permissions (Windows). What worked was just to create a copy from inside the msysgit source folder and use it (i.e. cp -rvf original original-bkup ).

A reset permissions in the source folder should work, but not.

+4
source share

Mark: If you have this error in Android Studio, just restart Android Studio and this error will be resolved. I guess this is due to some kind of “cache” or “error” of the intellij idea.

+22
source share

It happened to me too. And this is because I was busy downloading files on Windows from Linux (I have dual boot). I archived the files, then cloned the repository again and now I work as I should.

0
source share

All Articles