请帮助我,我试图在我的终端运行这个:

asgard@asgard-A7N8X2-0:~/CollegePortal$ git pull
error: cannot open .git/FETCH_HEAD: Permission denied

那我试试这个

asgard@asgard-A7N8X2-0:~/CollegePortal$ sudo git pull
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

帮帮我,我不明白这个问题。


当前回答

如果在Windows服务器上发现同样的问题,则需要运行具有足够权限的命令行,例如管理员权限。

其他回答

检查是否对.git/目录有足够的权限。你应该有写权限。可以使用下面的命令进行设置。

进入你的项目文件夹:

chown -R youruser:yourgroup .git/

当我在做包安装时,我得到:

Following files may not be writable, so sudo is needed:
  /Library/Ruby/Gems/2.6.0
  /Library/Ruby/Gems/2.6.0/bin
  /Library/Ruby/Gems/2.6.0/build_info
  /Library/Ruby/Gems/2.6.0/bundler
  /Library/Ruby/Gems/2.6.0/cache
  /Library/Ruby/Gems/2.6.0/doc
  /Library/Ruby/Gems/2.6.0/extensions
  /Library/Ruby/Gems/2.6.0/gems
  /Library/Ruby/Gems/2.6.0/specifications
Fetching gem metadata from https://rubygems.org/.........
error: cannot open .git/FETCH_HEAD: Permission denied

我已经按照这里的步骤更新了bash_profile,添加了一个rbenv shim。

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

但不知什么原因,我把它们删掉了。一旦我取消了注释,我就能够成功地运行bundle install。

如果您还没有将自己添加到拥有.git/的组中,那么您应该这样做。

sudo usermod -a -G $(stat -c '%G' .git) $USER
sudo chmod g+u .git -R
sudo chmod g+u .gitignore
su - $USER

它的作用:

找出拥有.git/的组,并将用户添加到该组。 确保组成员具有与.git/的所有者相同的权限。 为.gitignore重复此操作,您可能需要它 登出并重新登录,以刷新组成员文件权限

如果你最近做了类似的事情(将自己添加到拥有.git/的组中),那么你需要在git拉取期间能够写入.git/FETCH_HEAD之前注销并重新登录。

如果你想给小组权限,

sudo chmod g+w .git -R

对我来说是最好的。

是操作系统

sudo chmod -R g+w .git 

我遇到了完全相同的错误,但在我的情况下,这个问题是在升级到PHP版本后重新构建Apache的结果。长话短说,我忘了安装Apache模块“suexec”。

这与集团或所有权无关。我只用了两天就想明白了,有人朝我开枪…