Git gives me a "Permission Denied" error when writing files that I am pulling

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.