'Error on git pull error : cannot open .git/FETCH_HEAD: Permission denied
I'm looking for help !!
I am getting the following error message when trying to complete a git pull;
C:\Jenkins\Repo> git pull error: cannot open .git/FETCH_HEAD: Permission denied
The machine in question is Windows Server 2008 r2 OS and were using ssh to handle the authentication.
We have tried the following; Checked that the current user the correct read/write on the FETCH_HEAD file, which it does, also checking that the user has the correct permissions set on the repo root.
I have tried to load my private key (which I know 100% works and has permissions to the repo in question) and still the same issue... so from little I know regarding git I think this is more of a Windows issue
and lots of Google !
Any more ideas on what to do/check would be a great help !
Solution 1:[1]
This happened to me after I upgraded to Windows 10. While my user is an administrator and Administrators had full access to the root repo folder, my user was not explicitly listed. I've added my user with Full Control and it solved the problem for me (had the same issue with Outlook refusing to read the PST file until I did the same thing).
So, for me, the solution is:
- Right click on the folder, select properties
- Security
- Edit
- Add
- Type in my user name
- Check Full Control under Allow
- OK, OK
Solution 2:[2]
On Windows 10 this is what worked for me:
1. go to the repo folder
2. right click on the .git folder and choose the last option - properties
3. on the general tab uncheck hidden checkbox if checked
4. hit apply and then ok
now go try git fetch or git pull and it should work.
Solution 3:[3]
This is fairly a common problem. I've come across it many times and almost all of the times, the issue is with the right permissions to the repo/directory .git/
and the right SSH keys to access the git repository.
You probably need to make the user, the owner of the repository chown
(Give full access to the user) or, clone the repository to a different directory.
You can set the write permission with the following command
go to your folder chown -R youruser:yourgroup .git/
Also try to un-hide the .git folder.
Solution 4:[4]
In my case, this happend because I hide the .git
folder by hand(usually it will be hide automatically) but I forgot it.
I have tried edit security but no effect. So I just show the .git
folder and solve the problem.
May this can be help for someone
Solution 5:[5]
This happened to me because after updating windows. Kindly try these steps:
- Right click on folder -> properties
- Under general there are two checkbox hidden and read only -> uncheck the hidden check box and click on apply
- Under security -> edit -> add user -> apply
- give full access to your user
This will work for you
Solution 6:[6]
just remove the folder,and clone again.
Solution 7:[7]
What I did was open powershell / command prompt with Administrative rights inside the repository, and I was able to pull / fetch / merge and push.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | David Airapetyan |
Solution 2 | Akash Yellappa |
Solution 3 | Anantha Raju C |
Solution 4 | ysjiang |
Solution 5 | user13961704 |
Solution 6 | Chuancey |
Solution 7 | Joseph Wambura |