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

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

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


当前回答

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

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。

其他回答

这是一个UNIX权限问题。不要使用sudo来克隆存储库。您没有与根用户相同的ssh密钥,而且您不应该以根用户身份工作。尝试ls -la查找文件的权限,并使用chmod(或sudo chown)来修复它们。希望这能有所帮助。

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

进入你的项目文件夹:

chown -R youruser:yourgroup .git/

当您没有给予.git文件夹足够的权限时,就会出现此问题。 要解决这个问题-

首先导航到您的工作目录。 输入命令- sudo chmod a+rw .git -R

希望能有所帮助!!

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

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目录的属主和所属组(首先进入。git的父目录)ll .git,查看目录的属主和所属组, 使用sudo usermod -a -G yourusername groupsofonwner将您的用户添加到所有者的组,然后登出=>登录和一切工作。

所以在总结中

进入git的父目录 $cd你的路径 找到.git目录的组所有者 $ ll . 将您的用户添加到该组 $usermod -a -G你的用户名ownergroupofgit 注销和登录系统后生效。 好好享受吧!)