Git 给了我一个“权限被拒绝”的信息写入我正在拉取的文件时出错
在我的 Windows 计算机上,当我提取存储库时,我得到:
error: unable to crate file <path to file> (Permission denied)
我认为问题可能是,当我查看文件夹的属性时,复选框内有一个正方形,我将其清除,以便不会读取任何文件或文件夹仅有的。
按“确定”并检查 Windows 是否应用了我的更改后,我再次看到了正方形!
我怎样才能让 Git 或 Windows 获得我的提交?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
使用
以管理员身份运行
运行 Git Bash 或您正在运行的控制台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.
在我遇到同样问题的情况下,是另一个程序( Atom )阻止了文件。关闭它有帮助。
因此,检查是否有任何其他程序、代码编辑器正在使用相同的文件,如果是,请将其关闭。
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.
添加这个对我来说以上答案都不起作用:如果您安装了它,请检查 Bitdefender 设置(或您拥有的其他安全软件)。它与受保护的文件夹一起运行,并可能阻止任何操作文件的尝试。例如,当使用 git bash、rm、vim 等命令时,所有命令都被视为单独的命令,并且需要单独的权限 - 不仅仅是 bash.exe 本身。
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.
我只是在中止变基后遇到了这种错误。结果发现有一个孤立的 git 进程正在锁定 .git 目录中的文件。
否则此答案中的脚本也可能有用。
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.
关闭 Windows UAC 似乎可以解决问题。
Turning off Windows UAC seemed to do the trick.
Windows 10 上的 Git Bash。该文件不是只读的,因此我关闭了 bash 窗口并再次打开,它起作用了。
Git Bash on Windows 10. The file was not read-only, so I closed the bash window and opened again and it worked.
我尝试了所有建议,但没有一个有效。然后我再次尝试现有的解决方案以检查是否有任何应用程序导致它。这是 Avast 防病毒软件!
I tried all suggestions, none worked. Then i tried existing solutions again to check if any app is causing it. It was Avast antivirus !!