git pull 时无法统计错误

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

Error cannot stat upon git pull

gitfilepermissions

提问by Fil

I tried to perform a git pull from a remote branch with the following command:

我尝试使用以下命令从远程分支执行 git pull:

$ git pull origin branch_name
username@private_repository's password:
From ssh://private_repository/path/project
 * tag               branch_name       -> FETCH_HEAD
error: cannot stat 'path/name/of/file': Permission denied
error: cannot stat 'path/name/of/file': Permission denied

But I get the following error:

但我收到以下错误:

error: cannot stat 'path/name/of/file': Permission denied 
error: cannot stat 'path/name/of/file': Permission denied

Does anyone know what this means and what can I do about it?

有谁知道这是什么意思,我能做些什么?

Thanks

谢谢

采纳答案by Tal Avissar

The explanation is easy -- you have a security problem with your permissions on your git files and repositories. You need to have permissions to pull your files from git.

解释很简单——您对 git 文件和存储库的权限存在安全问题。您需要具有从 git 中提取文件的权限。

If the directory permissions are 755 (rwxr-xr-x) including all parent directories, anyone can list the directory contents.

如果目录权限为 755 (rwxr-xr-x),包括所有父目录,则任何人都可以列出目录内容。

But you can't, so this usually means that the full directory path doesn't have 755 permissions. This also means that all parent directories must have +x permission.

但是你不能,所以这通常意味着完整的目录路径没有 755 权限。这也意味着所有父目录都必须具有 +x 权限。

回答by Tom Bowers

For those working with:

对于那些工作的人:

  • IntelliJ IDEA
  • Visual Studio
  • Notepad++
  • 智能创意
  • 视觉工作室
  • 记事本++

Closing the solution may resolve this error. The IDE's git tools may still have hold of the file(s) in question.

关闭解决方案可能会解决此错误。IDE 的 git 工具可能仍然保留有问题的文件。

回答by Bruce Lerner

I've started using Atom and found it to be the issue. The Atom file tree needed to be refreshed and the git issue resolved.

我已经开始使用 Atom 并发现它是问题所在。需要刷新 Atom 文件树并解决 git 问题。

回答by David Villamizar

I've had this problem repeatedly with Atom, closing Atom solved it for me every time. Close any application using files that might be affected by the pull.

我在 Atom 上反复遇到过这个问题,每次关闭 Atom 都为我解决了这个问题。使用可能受拉动影响的文件关闭任何应用程序。

回答by zipzit

I had a different solution to this error. I've been using atom.io as my development tool. I wanted to discard my latest trial work (via git clean -dffollowed by git checkout -- .) When I did that there were some residual empty directories showing in the directory tree within Atom.

我对这个错误有不同的解决方案。我一直在使用 atom.io 作为我的开发工具。我想放弃我最新的试用工作(viagit clean -df后跟git checkout -- .)当我这样做时,Atom 的目录树中显示了一些剩余的空目录。

Those empty directories were generating error: cannot stat 'path/name/of/directory': Permission deniedwhen I tried checking out an alternative branch within git. Way frustrating.

error: cannot stat 'path/name/of/directory': Permission denied当我尝试检查 git 中的替代分支时,这些空目录正在生成。令人沮丧。

The fix was to simply click on the directories within Atom in the directory tree, where they would immediately 'poof' disappear. Once they were gone, there were no more errors in git.

解决方法是简单地单击目录树中 Atom 中的目录,它们会立即“噗”地消失。一旦它们消失了,git 中就不再有错误了。

回答by joelmez4

I have been with the same problem, and the way that I figure out was restartmy code editor closing all files related to the project (Atom) and my git GUI (SourceTree). After that, you can change the Branch.

我遇到了同样的问题,我想出的方法是重新启动我的代码编辑器,关闭与项目 (Atom) 和我的 git GUI (SourceTree) 相关的所有文件。之后,您可以更改分支。

回答by Fernando

In my case it was windows explorer who blocked de files. I restarted it with task manager (right mouse click, restart) and the issue was gone.

就我而言,是 Windows 资源管理器阻止了 de 文件。我用任务管理器重新启动它(鼠标右键单击,重新启动),问题就消失了。

回答by sezmeralda

My resolution was similar to most of the above:

我的决议与上述大多数类似:

  • I closed Visual Studio Code,
  • Closed any open file explorer windows,
  • Made sure none of my bash/powershell windows had the directory open.
  • 我关闭了 Visual Studio Code,
  • 关闭所有打开的文件资源管理器窗口,
  • 确保我的 bash/powershell 窗口都没有打开该目录。

This still didn't work for me. I ended up:

这仍然对我不起作用。我结束了:

  • Checking out a different branch,
  • Checking back in the branch I was trying to pull.
  • 检查不同的分支,
  • 重新检查我试图拉的分支。

This time when I ran git pullit worked.

这次我运行git pull它的工作。

回答by keshav kundal

I faced this issue when I tried to switch between two branches of a project. The reason why it happened was git tried to access the files that were left open in my code editor. I ran my editor as administrator and then switched to the other branch. It worked. I hope it helps someone out there!

当我尝试在项目的两个分支之间切换时遇到了这个问题。发生这种情况的原因是 git 试图访问在我的代码编辑器中保持打开状态的文件。我以管理员身份运行我的编辑器,然后切换到另一个分支。有效。我希望它可以帮助那里的人!

回答by malthoff

Also the Angular CLI can block your files. So make sure you stop ng serve from running.

此外,Angular CLI 可以阻止您的文件。因此,请确保停止运行 ng serve。