Fixing git ‘error: cannot open .git/ORIG_HEAD: Permission denied’

What

You want to run a git pull or some other git command but gets a failed message with an error message closely similar to below, usually FETCH_HEAD or ORIG_HEAD objects:

When

This normally occurs when the current user have incorrect permissions for .git files or directories.

Make sure that one of the following users within the system, either of www-data, git or the current non sudo user has proper access.

Git normal operations are better with non sudo and non superuser account to prevent similar permission nightmares.

How

Goto the parent directory of .git folder. In this example, we are using the current non privileged account

Then,