Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to access '/Users/dida/.config/git/attributes': Permission denied

When I do some git operations, such as 'git diff' or 'git add .', it shows that warning:

unable to access '/Users/dida/.config/git/attributes': Permission denied 

I wonder which config I did wrong and how can I fix it?
It's better with some commands, I am using mac command line

like image 223
Jing Lan Avatar asked Jul 20 '17 03:07

Jing Lan


3 Answers

Seems you've run sudo -H and sudo changed the ownership of some files to root. Take the files back:

sudo chown -R dida /Users/dida
like image 149
phd Avatar answered Oct 18 '22 08:10

phd


Cause

Git reads config settings from a variety of paths and the doesn't have access to some of them.

Git tries to read root config setting instead of config settings due to the starting script using su command with do not reset environment variables option (-m):

/bin/su -m $USER -c "cd $BASE/logs && $BASE/bin/startup.sh &> /dev/null"

Bitbucket Server is being started as root with /etc/init.d/atlbitbucket start script. Since the init.d script calls start-bitbucket.sh which uses su -m this causes the environment variables for root to be preserved and atlbitbucket does not have permission to write in the root home directory.

Git was compiled from source using the default settings which prevents any users other than the one that compiled Git from running it

Resolution

Fix the permissions on the files and directories with regard to the Bitbucket Server user performing the command:

chown <USER>.<GROUP> -R /home/<USER>/.config
chown <USER>.<GROUP> -R /home/<USER>/.gitconfig

(info) Change the USER.GROUP by your username and group in your OS.

If Bitbucket Server starting script have su command, make sure that the option -m is not used.

If Bitbucket Server is being started with /etc/init.d/atlbitbucket start switch to starting Bitbucket Servering with service atlbitbucket start

To have Bitbucket Server automatically start at boot, run chkconfig atlbitbucket on

Recompile Git using more sensible defaults:

make prefix=/usr/local/git all
make prefix=/usr/local/git install

or maybe this articles could help you https://confluence.atlassian.com/bitbucketserverkb/permission-denied-on-git-config-file-779171763.html

like image 23
Ria Anggraini Avatar answered Oct 18 '22 10:10

Ria Anggraini


git uses the HOME and XDG_CONFIG_HOME environment settings to lookup the config files.

Make sure they are set properly, to your current user (check the result of the id command)

id -a

Check also git config -l --show-origin to see where Git is trying to access those config files.

like image 1
VonC Avatar answered Oct 18 '22 09:10

VonC