Git: index file open failed: Permission denied on "git status". Hosted on Bitbucket
Got the same error fatal: index file open failed: Permission denied
by run git status
, and I checked .git/index
by
$ ls -al .git/index
to my surprise, it's
---------- 1 Kjuly staff 768248 Sep 2 11:07 .git/index
I've no idea why & how it changed. Anyway, after I changed it's permission back to 644
by
$ chmod 644 .git/index
git status
works.
Make sure the .git directory and its files/subdirectories are owned and writable by your user. This sounds like the repository was either cloned under a different user account or as root user (e.g. through sudo
).
It does not matter where the remote of the repository is hosted, git status only accesses the local repository.