Git 在写入我正在提取的文件时给我一个“权限被拒绝”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9200556/
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
Git gives me a "Permission Denied" error when writing files that I am pulling
提问by rp.
On my Windows machine, when I pull my repo I get:
在我的 Windows 机器上,当我拉我的回购时,我得到:
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!
按确定并检查 Windows 是否应用了我的更改后,我又看到了方块!
How can I get Git or Windows to allow me to get my commits?
我怎样才能让 Git 或 Windows 允许我得到我的提交?
回答by manojlds
Run the Git Bash or the console you are running, with Run As Administrator
运行 Git Bash 或您正在运行的控制台,使用 Run As Administrator
回答by Volodymyr Kotylo
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.
怎么发生的?当我切换到另一个分支时,一些不存在的文件出现在我的工作副本中。我无法丢弃它们,也无法在文本编辑器中打开。
回答by Maciej Sikora
In my situation with the same problem it was another program ( Atom ) which blocked files. Closing it helped.
在我遇到同样问题的情况下,另一个程序( Atom )阻止了文件。关闭它有帮助。
So check if any other program, code editor is using the same files, if yes - turn it off.
所以检查是否有任何其他程序,代码编辑器正在使用相同的文件,如果是 - 将其关闭。
回答by luxandras
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.
为我添加这个,以上答案都不起作用:如果您安装了它,请检查 Bitdefender 设置(或您拥有的其他安全软件)。它使用受保护的文件夹运行,并可能阻止任何操作文件的尝试。例如,当使用 git bash、rm、vim 等命令时,所有这些命令都算作单独的并且需要单独的权限 - 不仅仅是 bash.exe 本身。
回答by jakub.g
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.
中止变基后,我刚刚遇到了这种错误。原来有一个孤立的git
进程正在锁定.git
目录中的文件。
Otherwise a script from this answermight also be useful.
否则,此答案中的脚本也可能有用。
回答by markau
Git Bash on Windows 10. The file was not read-only, so I closed the bash window and opened again and it worked.
Windows 10 上的 Git Bash。该文件不是只读的,所以我关闭了 bash 窗口并再次打开,它工作正常。
回答by rp.
Turning off Windows UAC seemed to do the trick.
关闭 Windows UAC 似乎可以解决问题。