git 分支结帐期间随机文件上的权限被拒绝错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13803039/
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-10 15:04:52  来源:igfitidea点击:

Permission denied errors on random files during branch checkout

gitgit-extensions

提问by bugged87

All of a sudden, I started receiving the following error when checking out my local master branch. The problematic file, as well as the error itself, appears to be random (sometimes the checkout works perfectly fine).

突然间,我在检查本地主分支时开始收到以下错误。有问题的文件以及错误本身似乎是随机的(有时结帐工作得很好)。

"c:\Program Files (x86)\Git\bin\git.exe" checkout --merge "master"
D   abc123.cs
error: unable to create file abc123.cs (Permission denied)
Switched to branch 'master'
Done
"c:\Program Files (x86)\Git\bin\git.exe" checkout --merge "master"
D   abc123.cs
error: unable to create file abc123.cs (Permission denied)
Switched to branch 'master'
Done

采纳答案by bugged87

Daniel Hilgarth'santi-virus suggestion in the comments reminded me that I had run (and prematurely canceled) file recovery scans shortly before the problem manifested.

Daniel Hilgarth在评论中反病毒建议提醒我,我在问题出现前不久运行了(并提前取消了)文件恢复扫描。

It's possible these scan processes were causing the problem if they didn't cancel properly.

如果这些扫描过程没有正确取消,则可能是这些扫描过程导致了问题。

Regardless, rebooting my machine fixed the issue.

无论如何,重新启动我的机器解决了这个问题。

回答by imsrgadich

Just closing the editor solved my issue. By the way, I was using Atom editor.

关闭编辑器就解决了我的问题。顺便说一下,我使用的是 Atom 编辑器。

回答by ahnbizcad

I don't know if you're using sublime text, but when I got the permission denied problem, I noticed there was a license notice popup; that tries to get you to donate to sublimetext3 every once in a while.

我不知道你是否在使用 sublime text,但是当我遇到权限被拒绝的问题时,我注意到有一个许可证通知弹出窗口;它试图让你每隔一段时间捐赠一次 sublimetext3。

Once I closed that popup and ran the commands again, the denied permission errors went away and everything worked fine.

一旦我关闭该弹出窗口并再次运行命令,被拒绝的权限错误就消失了,一切正常。

I extrapolate that other editors with popup notices may cause this issue.

我推断其他带有弹出通知的编辑器可能会导致此问题。

Rebooting, as bugged87 mentioned, would certainly get rid of any popups or notifications.

正如 bugged87 提到的那样,重新启动肯定会消除任何弹出窗口或通知。

回答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 Messias Tayllan

The same happened with me a time ago and I've closed my VScode, typed git checkoutand it worked!

前段时间我也发生了同样的情况,我已经关闭了我的 VScode,输入git checkout并且它起作用了!

回答by Deepak Rao

Closing my text editor (Atom) fixed it.

关闭我的文本编辑器 (Atom) 修复了它。

回答by Paulo Griiettner

For me, the solution is to open Windows Task Manager and kill any IIS running instance.

对我来说,解决方案是打开 Windows 任务管理器并杀死任何 IIS 运行实例。

回答by eli

Close VSCode and run git checkout master -fworked for me.

关闭 VSCode 并运行git checkout master -f对我有用。

回答by Brahim LAMJAGUAR

Same problem on Cmder console; I just closed it and it did the trick.

Cmder 控制台同样的问题;我刚刚关闭它,它就成功了。

回答by Ali Maddi

This is a mistake in the OS level and does not relate to Git!

这是OS层面的错误,与Git无关!

Sometimes the issue was resolved by closing the IDE and all the explorers, and sometimes it was solved by rebooting.

有时问题是通过关闭 IDE 和所有资源管理器来解决的,有时是通过重新启动来解决的。

But the best solution is to create another folder and clone the project in it. You can also delete old project after cloning. You would not see any permission denied issue in the new folder.

但最好的解决方案是创建另一个文件夹并在其中克隆项目。您还可以在克隆后删除旧项目。您不会在新文件夹中看到任何权限被拒绝问题。