git cannot open .git/FETCH_HEAD
Solution 1
This worked with me
sudo chown -R $(whoami) .git/
Solution 2
error: cannot open .git/FETCH_HEAD: Permission denied
Was one of the first errors that ever happened to me.
Perhaps you already knew, but this is possibly happening because of not having permissions for changing/viewing that directory.
The idea is to change the permissions, perhaps use:
chmod
or
chown
I found further answers here Trying to git pull with error: cannot open .git/FETCH_HEAD: Permission denied.
Solution 3
if you are using ubuntu, use sudo key word before.
sudo git pull
if you are using windows, use administrator mode
Solution 4
you can check for the permissions on the file,
ls -l /usr/local/Library/Taps/linode/cli/.git/FETCH_HEAD
and
ls -l /usr/local/.git/FETCH_HEAD
Admin
Updated on July 05, 2022Comments
-
Admin almost 2 years
I have CentOs. I make git and made owner's .git folders group "gitdevelopers". In group "gitdevelopers" add User1 and User2. Now i make git-push and git-pull change from user1 and user2. But users in your computers not work with error:
git.exe pull -v --no-rebase --progress "origin" error: cannot open .git/FETCH_HEAD: Permission denied
Why?
p.s.:And i can connect to server by x-shell with login-password user1 and user2.
few hours later:: I think problem in not right login-password, which git remember.
p.p.s: where git save login-password pairs? I use ssh-protocol.
p.p.p.s.:OK. I have server CentOs with git. On server is two users. And I use TortoiseGit for windows. I configure this so : in each connect system asked login and password for connect to server. And now I wanted know : 1. where is saved this login-password 2. i can permanently saved this pair?
-
Tarun Nagpal almost 4 yearsIt worked well. Can you please explain the logic behind it ?
-
Hasnat Safder over 3 yearssudo chown=change ownership of directory, -R=make it recursive, meaning of all sub folders and files inside that directory, $(whoami)=get current logged in user, .git/=is the folder where info about git repository is stored, Hence this command will change the ownership of file to current user, so this user can perform commands like "git pull" etc.