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

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:

sudo npm run deploy

其他回答

这个问题的答案是确保.git/FETCH_HEAD有写权限,这样你就全部设置好了。

我在Windows上遇到了这个问题,通过授予写权限解决了这个问题。

在unix中,可以从项目存储库中运行chmod a+rw .git/FETCH_HEAD,然后它就可以工作了。

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

sudo chown -R $USER:。

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

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

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

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

如果你想给小组权限,

sudo chmod g+w .git -R

对我来说是最好的。

是操作系统

sudo chmod -R g+w .git 

这将解析文件夹中的所有权限

sudo chown -R $(whoami) ./