Unable to access 'git/attributes'

Git

Git Problem Overview


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

$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?

Git Solutions


Solution 1 - Git

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.

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.

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)

The -R option with chown is to modify the permissions recursively. This will help if you have subfolders under ~/.config

Solution 2 - Git

I think your HOME envireonment variable is improperly set.

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

Solution 3 - Git

Go to root directory

cd ~/

Write the following code:

sudo chown -R username /Users/username

Where username is your system's username.

Solution 4 - Git

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.

Solution 5 - Git

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:

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.

Solution 6 - Git

For Windows, it may be a case when some process like CMD or SSH client opened some folder which Git tries to delete.

Solution 7 - Git

This is a problem with your user's privileges. You have to give yourself root privileges.

You can fix this problem temporarily by switching to root user. For this;

sudo su

Become root by doing it. Then you will need to add your git config settings here as well as you are migrating to a different user. For this too

git config user.email "[email protected]"
git config user.name "Your Name"

and then repeat your action again. it should work

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBasilevsView Question on Stackoverflow
Solution 1 - GitBlackVegetableView Answer on Stackoverflow
Solution 2 - GitAnshul GoyalView Answer on Stackoverflow
Solution 3 - GitArti PrasadView Answer on Stackoverflow
Solution 4 - GitVishalView Answer on Stackoverflow
Solution 5 - GitphaoostView Answer on Stackoverflow
Solution 6 - GitOleg NeumyvakinView Answer on Stackoverflow
Solution 7 - GitmrcoderView Answer on Stackoverflow