简体   繁体   English

git pull 时无法统计错误

[英]Error cannot stat upon git pull

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谢谢

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 工具可能仍然保留有问题的文件。

I've started using Atom and found it to be the issue.我已经开始使用 Atom 并发现它是问题所在。 The Atom file tree needed to be refreshed and the git issue resolved.需要刷新 Atom 文件树并解决 git 问题。

I've had this problem repeatedly with Atom, closing Atom solved it for me every time.我在 Atom 上反复遇到过这个问题,每次关闭 Atom 都为我解决了这个问题。 Close any application using files that might be affected by the pull.使用可能受拉动影响的文件关闭任何应用程序。

I had a different solution to this error.我对这个错误有不同的解决方案。 I've been using atom.io as my development tool.我一直在使用 atom.io 作为我的开发工具。 I wanted to discard my latest trial work (via git clean -df followed by git checkout -- . ) When I did that there were some residual empty directories showing in the directory tree within Atom.我想放弃我最新的试用工作(通过git clean -df后跟git checkout -- . )当我这样做时,Atom 的目录树中显示了一些剩余的空目录。

Those empty directories were generating error: cannot stat 'path/name/of/directory': Permission denied when I tried checking out an alternative branch within git.那些空目录产生error: cannot stat 'path/name/of/directory': Permission denied当我尝试检查 git 中的替代分支时。 Way frustrating.令人沮丧。

The fix was to simply click on the directories within Atom in the directory tree, where they would immediately 'poof' disappear.解决方法是简单地单击目录树中 Atom 中的目录,它们会立即“噗”地消失。 Once they were gone, there were no more errors in git.一旦它们消失了,git 中就不再有错误了。

I have been with the same problem, and the way that I figure out was restart my code editor closing all files related to the project (Atom) and my git GUI (SourceTree).我遇到了同样的问题,我想出的方法是重新启动我的代码编辑器,关闭与项目 (Atom) 和我的 git GUI (SourceTree) 相关的所有文件。 After that, you can change the Branch.之后,您可以更改分支。

The explanation is easy -- you have a security problem with your permissions on your git files and repositories.解释很简单——您对 git 文件和存储库的权限存在安全问题。 You need to have permissions to pull your files from 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.但是你不能,所以这通常意味着完整的目录路径没有 755 权限。 This also means that all parent directories must have +x permission.这也意味着所有父目录都必须具有 +x 权限。

In my case it was windows explorer who blocked de files.就我而言,是 Windows 资源管理器阻止了 de 文件。 I restarted it with task manager (right mouse click, restart) and the issue was gone.我用任务管理器重新启动它(鼠标右键单击,重新启动),问题就消失了。

Also the Angular CLI can block your files.此外,Angular CLI 可以阻止您的文件。 So make sure you stop ng serve from running.因此,请确保停止运行 ng serve。

My resolution was similar to most of the above:我的决议与上述大多数类似:

  • I closed Visual Studio Code,我关闭了 Visual Studio Code,
  • Closed any open file explorer windows,关闭所有打开的文件资源管理器窗口,
  • Made sure none of my bash/powershell windows had the directory open.确保我的 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 pull it worked.这次当我运行git pull它起作用了。

what worked for me is to run sourcetree and visual studio in administrator mode对我有用的是在管理员模式下运行 sourcetree 和visual studio

right click on icon(sourcetree or visual studio) and you should see an option 'Run as administrator'右键单击图标(sourcetree 或visual studio),您应该会看到一个选项“以管理员身份运行”

在此处输入图片说明

Alternatively go to properties for particular application and in tab Shortcut select Advanced and tick option 'Run as administrator'或者转到特定应用程序的属性并在选项卡快捷方式中选择高级并勾选选项“以管理员身份运行”

在此处输入图片说明

Yup, so I just got here and have an easy fix for Visual Studio users.是的,所以我刚到这里并为 Visual Studio 用户提供了一个简单的修复。

If you do a checkout of a branch, but haven't set Visual Studio to the focus, it will have a temporarily lock on the files.如果您签出一个分支,但尚未将 Visual Studio 设置为焦点,它将暂时锁定文件。

Once you click on VS and allow it to reload the project files, you should be able to pull again...user error here一旦你点击 VS 并允许它重新加载项目文件,你应该能够再次拉...用户错误在这里

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.发生这种情况的原因是 git 试图访问在我的代码编辑器中保持打开状态的文件。 I ran my editor as administrator and then switched to the other branch.我以管理员身份运行我的编辑器,然后切换到另一个分支。 It worked.它奏效了。 I hope it helps someone out there!我希望它可以帮助那里的人!

I got this after doing a git pull --all我在执行git pull --all后得到了这个

a git pull resolved the issue一个git pull解决了这个问题

I think the root of the issues was the fact that some branches had been deleted on the server.我认为问题的根源在于服务器上的某些分支已被删除。

Your git environment isn't set up correctly.您的 git 环境设置不正确。

Repos should be owned by user git. Repos 应该归用户 git 所有。 So user git should accept your public key.所以用户 git 应该接受你的公钥。

Not sure what backend you're working with here, so the method for adding your key will vary.不确定您在这里使用的是什么后端,因此添加密钥的方法会有所不同。

I had npm run watch for VueJS running in a background process which I forgot about which was causing git to block any changes when restoring from stash.我有npm run watch for VueJS 在后台进程中运行,我忘记了这会导致 git 在从存储恢复时阻止任何更改。 So be aware of that!所以要注意这一点!

I closed Visual studio Code in which project was present, but still issue persisted : error : cannot stat, permission denied.我关闭了存在项目的 Visual Studio Code,但问题仍然存在:错误:无法统计,权限被拒绝。

Then I saw grunt was running, so I closed grunt and did check out again and issue was resolved !然后我看到 grunt 正在运行,所以我关闭了 grunt 并再次检查并解决了问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM