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

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

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


当前回答

错误:不能打开。git/FETCH_HEAD:权限被拒绝

这对我来说很有用:

默认情况下。git文件夹是隐藏的。 取消隐藏。git文件夹及其子文件夹和文件,并尝试拉请求。

其他回答

使用这个命令,它对我有用。

sudo chown -R $USER:。

参考:https://techoverflow.net/2019/05/07/how-to-fix-git-error-cannot-open-git-fetch_head-permission-denied/

这个错误的原因可能是多重的,但在我的情况下,我更新了根分支,然后当我试图更新它与普通用户它给我错误。

尝试两种解决方案,其中一种应该对你有效

1- sudo chmod g+w .git -R

如果它不工作,请尝试下一个解决方案,希望它能解决你的问题

2 - rm -f .git/FETCH_HEAD

试试这样吧,

第一步:首先确认你是谁?它将返回当前用户名,例如ubuntu

$ whoami 

步骤2:然后设置您当前用户的权限,在这种情况下,ubuntu by

sudo chown -R ubuntu .git/

错误消息“不能打开.git/FETCH_HEAD: Too many links”表示指向该文件的硬链接太多,可能超过了文件系统允许的最大限制。

要解决此问题,您可以尝试以下步骤:

Git branch——merged | grep -v "\*" | xargs -n 1 Git branch -d 运行git gc来清理存储库并减少对象和链接的数量。 如果上述步骤不起作用,您可能需要将存储库克隆到一个新目录并删除原始目录。

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

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。