Could not create file ... Permission denied

I am currently working on windows.

Sometimes I have problems when I try:

git checkout origin develop 

I have this error: Error: cannot create file ....: Permission denied

"git status" show me that the file wasn’t delivered by mistake, so I need to commit

What do i need to check?

I tried to execute this command line on my computer:

 chown -R username directory 

We have people working on the git repository, and they have a problem too.

thanks for the help

+30
source share
10 answers

In my case, my corner app was still working with ng serve , giving the following:

Git Bash - ng serve

So I just had to close it with ctrl+c

+49
source

I had the same problem and the problem was in open files. Make sure you don’t have any files that git is trying to create anywhere; close localhost browser tabs if any files are open there; close all links to files with which you work. This is what worked for me.

+9
source

First, make sure you run your cmd / terminal as an administrator (right-click the cmd.exe icon β†’ "Run as administrator")

I had the same issue with git pull (using cmder on windows). What worked for me:

This will remove the local changes:
hard reset your branch and try again.
$ git checkout origin develop - (failed)
$ git reset --hard HEAD
$ git checkout origin develop - (great success!)

If this does not work, try checking:
This will also discard your local changes.
$ git checkout -f origin develop .

+6
source

In my case, the "npm run dev" to build the web package in my React application still worked with a compilation error. interrupt with Ctrl + C fix this

+3
source

For me it was that I was running npm run watch in the linux subsystem (wsl), running it in regular cmd, fixed this.

+1
source

None of the proposed solutions helped in this case of this problem.

Finally (after many desperate unsuccessful attempts), what did the job was a good old PC reboot.

+1
source

I ran into the same problem. If your code works, stop it (i.e. close the terminal where npm run *** is running) and close Visual Studio. Open it again and run the git checkout development command again. It worked for me.

0
source

This happened to me on Linux. I just renamed the folder with the error file and from the top extraction directory I started git checkout. who solved the problem.

0
source

In my case, I had to run the git command with sudo : sudo git checkout

0
source

When developing VS Code Remote-WSL, the same problem arose. I tried to kill NodeJS processes, but some of them were open from previous sessions that did not want to die. In the end, I had to restart WSL and happy times.

Restart WSL (first save the files if something opens in WSL):

In Windows WIN + R β†’ services.msc β†’ Find LxssManager β†’ Right-click β†’ Reload

0
source

All Articles