'Git gives me a "Permission Denied" error when writing files that I am pulling
On my Windows machine, when I pull my repo I get:
error: unable to crate file <path to file> (Permission denied)
I think the problem might be that when I look at the properties of the folder there is a square inside the checkbox, I clear it out so that no files or folders will be read only.
After pressing ok and checking to see if Windows applied my changes, I see the square again!
How can I get Git or Windows to allow me to get my commits?
Solution 1:[1]
Check if another application is using your files and kill it. In my case it was grunt, always watching for the changes and building project. Gave me the same message as yours, when discarding files.
How it happened? When I've switched to another branch, some non-existent files appeared in my working copy. I could not Discard them, nor open in the text editor.
Solution 2:[2]
In my situation with the same problem it was another program ( Atom ) which blocked files. Closing it helped.
So check if any other program, code editor is using the same files, if yes - turn it off.
Solution 3:[3]
Adding this as for me none of the above answers worked: if you have it installed, check Bitdefender settings (or other security software you have). It operates with protected folders and might block any attempts to manipulate files. When using for example git bash, commands like rm, vim, etc., all count as separate ones and need separate permissions - not only bash.exe itself.
Solution 4:[4]
I just had this kind of error after aborting a rebase. Turned out there was an orphaned git process that was keeping a lock on a file in .git directory.
Otherwise a script from this answer might also be useful.
Solution 5:[5]
Turning off Windows UAC seemed to do the trick.
Solution 6:[6]
Git Bash on Windows 10. The file was not read-only, so I closed the bash window and opened again and it worked.
Solution 7:[7]
I tried all suggestions, none worked. Then i tried existing solutions again to check if any app is causing it. It was Avast antivirus !!
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 | Volodymyr Kotylo |
| Solution 2 | Maciej Sikora |
| Solution 3 | luxandras |
| Solution 4 | Community |
| Solution 5 | rp. |
| Solution 6 | markau |
| Solution 7 | Dheemanth Bhandarkar |
