git 无法创建文件...权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38561400/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:24:27  来源:igfitidea点击:

unable to create file ... Permission denied

git

提问by pop_up

i am currently working on windows.

我目前在 Windows 上工作。

Sometimes i have problems when i try :

有时我在尝试时遇到问题:

git checkout origin develop

i have this error : error: unable to create file .... : Permission denied

我有这个错误:错误:无法创建文件....:权限被拒绝

"git status" show me the file in error not staged so i have to commit

“git status”显示错误的文件没有暂存所以我必须提交

What do i have to check ?

我需要检查什么?

i tried to do this command line on my computer :

我试图在我的电脑上执行这个命令行:

chown -R username directory

We are severals people to work on a git repository and they have the problem too.

我们有几个人在 git 存储库上工作,他们也有问题。

thanks for you help

谢谢你的帮助

回答by Leo

In my case, my angular app was still running from ng serve, giving this:

就我而言,我的 angular 应用程序仍在运行ng serve,给出了:

Git Bash - ng serve

Git Bash - ng serve

So I just had to close it with ctrl+c.

所以我只需要用ctrl+c.

回答by Dave

I had the same issue and the problem was open files. Make sure you don't have the files git is trying to create open anywhere; close your localhost browser tabs if any of the files are open there; close all references to the files you are working with. That's what worked for me.

我有同样的问题,问题是打开文件。确保你没有在任何地方打开 git 试图创建的文件;如果有任何文件在那里打开,请关闭您的本地主机浏览器选项卡;关闭对您正在使用的文件的所有引用。这就是对我有用的东西。

回答by Taitu-lism

First make sure to run your cmd/terminal as an administrator (right click on cmd.exe icon -> "Run as Administrator")

首先确保以管理员身份运行您的 cmd/终端(右键单击 cmd.exe 图标 ->“以管理员身份运行”)

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

我有同样的问题git pull(在 Windows 上使用 cmder)。对我有用的是:

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

这将删除您的本地更改:
硬重置您的分支并重试。
$ git checkout origin develop- (失败)
$ git reset --hard HEAD
$ git checkout origin develop- (大获成功!)

If this doesn't work try forcing the checkout:
This will also throw away your local changes
$ git checkout -f origin develop.

如果这不起作用,请尝试强制结帐:
这也会丢弃您的本地更改
$ git checkout -f origin develop

回答by ykorach

In my case, "npm run dev", for webpack build to my React app was still running with failed to compile error. aborting it with ctrl+c fix it

在我的例子中,“npm run dev”,用于构建到我的 React 应用程序的 webpack 仍然在运行,但出现编译失败错误。使用 ctrl+c 中止它修复它

回答by pcpie

For me it was that I was running npm run watchin a linux subsystem (wsl) running it in a normal cmd fixed it.

对我来说,我npm run watch在一个 linux 子系统(wsl)中运行,在一个普通的 cmd 中运行它修复了它。

回答by kyselm

None of the provided solutions helped in my case of this problem.

在我遇到这个问题的情况下,提供的解决方案都没有帮助。

Finally (after many desperate unsuccessful attempts) the thing that did the work was good old PC reboot.

最后(经过多次绝望的失败尝试),完成这项工作的事情是重新启动旧 PC。

回答by JustAnotherGirl

I was facing the same issue. If your code is running, Stop it (i.e close the terminal on which npm run *** is working) and close Visual Studio. Re-open it and again run the command git checkout develop . It worked for me.

我面临着同样的问题。如果您的代码正在运行,请停止它(即关闭 npm run *** 正在运行的终端)并关闭 Visual Studio。重新打开它并再次运行命令 git checkout develop 。它对我有用。

回答by SamK

This was happening to me on linux. I just renamed the folder with the offending file and from the top directory of the checkout ran a git checkout . which solved the problem.

这发生在我在 linux 上。我刚刚用有问题的文件重命名了文件夹,并从结帐的顶级目录运行了 git checkout 。这解决了问题。

回答by gustavoknz

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

就我而言,我必须使用sudo以下命令运行 git 命令:sudo git checkout

回答by Riga

Had same problem developing from VS Code Remote-WSL. Tried to kill NodeJS processes but had some open from previous sessions that didn't want to die. At the end had to restart the WSL and happy times.

从 VS Code Remote-WSL 开发时遇到了同样的问题。试图杀死 NodeJS 进程,但从不想死的先前会话中打开了一些进程。最后不得不重新启动 WSL 和快乐时光。

Restart WSL(mind to save files first if something open in WSL):

重新启动 WSL(如果在 WSL 中打开了某些内容,请注意先保存文件):

In Windows WIN+R -> services.msc -> Find LxssManager -> Right-click -> Restart

在 Windows 下 WIN+R -> services.msc -> 找到 LxssManager -> 右键单击​​ -> 重新启动