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

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

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


当前回答

sudo chmod -R 777 .git或者如果你想为自己添加rw权限,你可以使用sudo chmod -R +rw .git

其他回答

就我而言,

sudo chmod ug+wx .git -R

此命令有效。

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

进入你的项目文件夹:

chown -R youruser:yourgroup .git/

运行Windows 7,当我遇到这个问题时,是因为我隐藏了。git文件夹。权限没有问题,只是被隐藏了。显示文件夹解决了这个问题。

只需转到您的根文件夹并运行以下命令:

chmod a+rw .git/FETCH_HEAD

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

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。