How to fix git 'error: cannot open .git/FETCH_HEAD: Permission denied'
Problem:
You want to run git pull or some other git command but you only see this error message:
git_permission_error.txt
error: cannot open .git/FETCH_HEAD: Permission deniedSolution
This means that the .git directory is not owned by you. The easiest way to fix that is to change the owner of the directory to your user.
First, go to the root directory of the repository using cd, if you are not already there.
Then,
fix_git_permissions.sh
sudo chown -R $USER: .In case you don’t have sudo access on that computer, the easiest way is to copy the repository to a directory where you have write access (e.g. using cp -r) or even clone the repository again.
Check out similar posts by category:
Git, Version Management
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow