windows git pull 错误:无法打开 .git/FETCH_HEAD:权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32378984/
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
Error on git pull error : cannot open .git/FETCH_HEAD: Permission denied
提问by craig Rickett
I'm looking for help !!
我在寻求帮助!!
I am getting the following error message when trying to complete a git pull;
尝试完成 git pull 时收到以下错误消息;
C:\Jenkins\Repo> git pull error: cannot open .git/FETCH_HEAD: Permission denied
C:\Jenkins\Repo> git pull 错误:无法打开 .git/FETCH_HEAD:权限被拒绝
The machine in question is Windows Server 2008 r2 OS and were using ssh to handle the authentication.
有问题的机器是 Windows Server 2008 r2 操作系统,并且使用 ssh 来处理身份验证。
We have tried the following;Checked that the current user the correct read/write on the FETCH_HEAD file, which it does, also checking that the user has the correct permissions set on the repo root.
我们尝试了以下方法;检查当前用户是否对 FETCH_HEAD 文件进行了正确的读/写操作,并检查用户是否在 repo root 上设置了正确的权限。
I have tried to load my private key (which I know 100% works and has permissions to the repo in question) and still the same issue... so from little I know regarding git I think this is more of a Windows issue
我试图加载我的私钥(我知道它 100% 有效并且对相关的 repo 有权限)但仍然是同样的问题......所以我对 git 知之甚少,我认为这更像是一个 Windows 问题
and lots of Google !
和很多谷歌!
Any more ideas on what to do/check would be a great help !
关于做什么/检查的更多想法将是一个很大的帮助!
回答by David Airapetyan
This happened to me after I upgraded to Windows 10. While my user is an administrator and Administrators had full access to the root repo folder, my user was not explicitly listed. I've added my user with Full Control and it solved the problem for me (had the same issue with Outlook refusing to read the PST file until I did the same thing).
在我升级到 Windows 10 后,这发生在我身上。虽然我的用户是管理员并且管理员拥有对根 repo 文件夹的完全访问权限,但我的用户没有明确列出。我已经添加了我的用户完全控制,它为我解决了这个问题(在我做同样的事情之前,Outlook 拒绝读取 PST 文件有同样的问题)。
So, for me, the solution is:
所以,对我来说,解决方案是:
- Right click on the folder, select properties
- Security
- Edit
- Add
- Type in my user name
- Check Full Control under Allow
- OK, OK
- 右击文件夹,选择属性
- 安全
- 编辑
- 添加
- 输入我的用户名
- 在允许下检查完全控制
- 好的好的
回答by Anantha Raju C
This is fairly a common problem. I've come across it many times and almost all of the times, the issue is with the right permissionsto the repo/directory .git/
and the right SSH keys to access the git repository.
这是一个相当普遍的问题。我遇到过很多次,几乎所有的时候,问题都在于对 repo/目录的正确权限.git/
以及访问 git 存储库的正确 SSH 密钥。
You probably need to make the user, the owner of the repository chown
(Give full access to the user) or, clone the repository to a different directory.
您可能需要让用户成为存储库的所有者chown
(授予用户完全访问权限)或将存储库克隆到不同的目录。
You can set the write permission with the following command
go to your folder chown -R youruser:yourgroup .git/
您可以使用以下命令设置写入权限转到您的文件夹 chown -R youruser:yourgroup .git/
Also try to un-hide the .git folder.
还尝试取消隐藏 .git 文件夹。
回答by Akash Yellappa
On Windows 10 this is what worked for me:
在 Windows 10 上,这对我有用:
1. go to the repo folder
2. right click on the .git folder and choose the last option - properties
3. on the general tab uncheck hidden checkbox if checked
4. hit apply and then ok
now go try git fetch or git pull and it should work.
现在去尝试 git fetch 或 git pull ,它应该可以工作。
回答by ysjiang
In my case, this happend because I hide the .git
folder by hand(usually it will be hide automatically) but I forgot it.
就我而言,发生这种情况是因为我.git
手动隐藏了文件夹(通常它会自动隐藏)但我忘记了。
I have tried edit security but no effect. So I just show the .git
folder and solve the problem.
我试过编辑安全性,但没有效果。所以我只是显示.git
文件夹并解决问题。
May this can be help for someone
可能这对某人有帮助