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?
Run the Git Bash or the console you are running, with Run As Administrator
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.
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.
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.
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.
Turning off Windows UAC seemed to do the trick.
Git Bash on Windows 10. The file was not read-only, so I closed the bash window and opened again and it worked.