Unable to access 'git/attributes'

remote: warning: unable to access '/root/.config/git/attributes': Permission denied警告意味着什么? 它会带来什么影响?

$git clone git://git.eclipse.org/gitroot/egit/egit.git
Cloning into 'egit'...
remote: warning: unable to access '/root/.config/git/attributes': Permission denied
remote: Counting objects: 57926, done.
remote: Compressing objects: 100% (11872/11872), done.
remote: Total 57926 (delta 30734), reused 56308 (delta 29136)
Receiving objects: 100% (57926/57926), 32.29 MiB | 1021 KiB/s, done.
Resolving deltas: 100% (30734/30734), done.
Checking out files: 100% (1483/1483), done.

我应该向主机报告潜在的基础设施问题吗?

95727 次浏览

我认为您的 HOME环境变量设置不正确。

google group thread,

HOME 环境变量被设置为 /root,所以它查看 /root/.gitconfig/root/.config/git/config,因为非特权用户无法访问 /root,它抛出了一个错误。

因此,我的解决方案是将 HOME env 设置为用户的 HOME 目录

Git 试图从 root 读取 config 而不是用户 config。请检查您的环境变量是否具有正确的 git 配置集或。可以访问主文件夹中的 gitconfig 文件。

我自己也遇到过这种情况。在确认它正在 ~/.config/中查找之后,我注意到该文件夹的所有者是 root。我把这个改成了 my_user_name,它起作用了。

cd ~/
ls -al
<Noticed .config was owned by root, unlike everything else in $HOME>
sudo chown -R $(whoami) .config

这也有助于了解原因: 这个目录是在您第一次运行使用它的程序时创建的。如果命令作为 root运行,将导致此权限问题。

For example, if the ~/.config directory does not yet exist, and you run sudo htop, the directories ~/.config and ~/.config/htop will be created and owned by root. Afterward, a regular git command wont be able to access ~/.config and will give the above warning. (Credit: user mehtunguh)

chown-R选项是递归地修改权限。如果在 ~/.config下有子文件夹,这将有所帮助

我已经运行了类似的问题,并能够在服务器端修复它。Git 在 uwsgi 下运行,所以我在 uwsgi config 中添加了以下代码行:

env = HOME=/srv/git

其中/srv/git 所属的 uid 与运行 uwsgi 并制作 chmod u+rwX /srv/git的 uid 相同 因此,您需要将运行 git 的进程的 HOME 变量指向该进程将具有读/写/遍历权限的目录。

进入根目录

cd ~/

编写以下代码:

sudo chown -R username /Users/username

其中用户名是系统的用户名。

对于 Windows 来说,当一些进程(如 CMD 或 SSH 客户端)打开 Git 试图删除的某个文件夹时,可能会出现这种情况。

这是您的用户权限的问题。您必须给自己 root 权限。

您可以通过切换到 root 用户来临时修复此问题

sudo su

通过这样做成为根。然后,您将需要在这里添加您的 git 配置设置,以及您正在迁移到不同的用户。还有这个

git config user.email "you@example.com"
git config user.name "Your Name"

然后 重复你的动作。 应该能行