无法访问“git/attributes”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27150926/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:41:51  来源:igfitidea点击:

Unable to access 'git/attributes'

git

提问by Basilevs

What does warning remote: warning: unable to access '/root/.config/git/attributes': Permission deniedmeans and what implications does it bring?

警告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.

Should I report potential infrastructure problem to hoster?

我应该向托管人报告潜在的基础设施问题吗?

回答by BlackVegetable

I ran into this situation myself. After verifying that it was looking in ~/.config/I noticed the owner of that folder was root. I changed this to my_user_nameand it worked.

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

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

It helps to know the cause as well: This directory is created the first time you run a program that uses it. If the command was run as root, it will cause this permissions problem.

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

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

例如,如果~/.config目录尚不存在,而您运行sudo htop,则目录~/.config~/.config/htop将由root. 之后,常规的 git 命令将无法访问~/.config并给出上述警告。(信用:用户mehtunguh)

The -Roption with chownis to modify the permissions recursively. This will help if you have subfolders under ~/.config

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

回答by u1860929

I think your HOMEenvireonment variable is improperly set.

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

From the google group thread,

谷歌组线程

the HOME environment variable was set to /rootso it looked at /root/.gitconfigor /root/.config/git/configsince the unprivileged user didn't have access to /rootit threw an error.

So the solution was for me to set the HOME env to the user's HOME directory

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

所以解决方案是我将 HOME env 设置为用户的 HOME 目录

回答by Vishal

Git is trying to read config from root instead of user config. Please check your environment variables have the correct git config set or the .gitconfig file in your home folder is accessible.

Git 试图从 root 而不是用户配置读取配置。请检查您的环境变量是否设置了正确的 git 配置,或者您的主文件夹中的 .gitconfig 文件是否可访问。

回答by Arti Prasad

Go to root directory

进入根目录

cd ~/

cd ~/

Write the following code:

编写以下代码:

sudo chown -R username /Users/username

sudo chown -R username /Users/username

Where username is your system's username.

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

回答by phaoost

I've ran the similar issue and was able to fix it on server side. git runs there under uwsgi so I added in uwsgi config the following line:

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

env = HOME=/srv/git

where /srv/git is owned by the same uid that uwsgi runs under and made chmod u+rwX /srv/gitSo, you need to point HOME variable on server side for the process that runs git to the directory where this process will have reading/writing/traverse permissions.

其中 /srv/git 由 uwsgi 在其下运行并生成的相同 uid 所有chmod u+rwX /srv/git因此,您需要将服务器端的 HOME 变量指向运行 git 的进程的目录,该进程将具有读/写/遍历权限。

回答by karma_police

Also you can check owner of /root/.config/git/folder on your machine

您也可以检查/root/.config/git/机器上文件夹的所有者