简体   繁体   中英

Error cannot stat upon git pull

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

$ 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.

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.

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.

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 -df followed by git checkout -- . ) When I did that there were some residual empty directories showing in the directory tree within 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. Way frustrating.

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.

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). 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. You need to have permissions to pull your files from git.

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

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.

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.

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

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.

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.

what worked for me is to run sourcetree and visual studio in administrator mode

right click on icon(sourcetree or visual studio) and you should see an option 'Run as administrator'

在此处输入图片说明

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.

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.

Once you click on VS and allow it to reload the project files, you should be able to pull again...user error here

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!

I got this after doing a git pull --all

a git pull resolved the issue

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.

Repos should be owned by user git. So user git should accept your public key.

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. So be aware of that!

I closed Visual studio Code in which project was present, but still issue persisted : error : cannot stat, permission denied.

Then I saw grunt was running, so I closed grunt and did check out again and issue was resolved !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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