无法访问“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
Unable to access 'git/attributes'
提问by Basilevs
What does warning remote: warning: unable to access '/root/.config/git/attributes': Permission denied
means 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_name
and 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 ~/.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)
例如,如果~/.config
目录尚不存在,而您运行sudo htop
,则目录~/.config
和~/.config/htop
将由root
. 之后,常规的 git 命令将无法访问~/.config
并给出上述警告。(信用:用户mehtunguh)
The -R
option with chown
is to modify the permissions recursively. This will help if you have subfolders under ~/.config
在-R
与选项chown
是递归地修改权限。如果您有子文件夹,这将有所帮助~/.config
回答by u1860929
I think your HOME
envireonment variable is improperly set.
我认为您的HOME
环境变量设置不正确。
From the google group thread,
从谷歌组线程,
the HOME environment variable was set to
/root
so it looked at/root/.gitconfig
or/root/.config/git/config
since the unprivileged user didn't have access to/root
it 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/git
So, 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/
机器上文件夹的所有者