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

喜你入骨 提交于 2019-12-06 23:24:00

问题


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


回答1:


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



回答2:


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




回答3:


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.




回答4:


try sudo -u user --set-home git clone http://github.com/repohere this worked for me.



来源:https://stackoverflow.com/questions/45204413/unable-to-access-users-dida-config-git-attributes-permission-denied

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!