Unable to access ‘git/attributes’

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

Leave a Comment