Failed to access '/Users/dida/.config/git/attributes': permission denied

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

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

I wonder what configuration I did wrong and how to fix it?
This is better with some commands, I use mac command line

+5
source share
3 answers

Cause

Git reads configuration settings from different paths and does not have access to some of them.

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

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

The Bitbucket server is started as root using the /etc/init.d/atlbitbucket start script. Since the init.d script calls start-bitbucket.sh, which uses su -m, this means that the environment variables for root are saved and atlbitbucket does not have write permissions to the root home directory.

Git was compiled from the source using the default settings, which forbid other users than compiling Git to execute it

Resolution

Correct the rights to files and directories regarding the user of the Bitbucket server that runs the command:

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

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

If the Bitbucket server, starting with the script, has the su command, make sure the -m option is not used.

If the Bitbucket server is started by running /etc/init.d/atlbitbucket start start to start the Bitbucket server and start the atlbitbucket service

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

Recompile Git using more reasonable defaults:

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

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

+1
source

git uses the HOME and XDG_CONFIG_HOME environment parameters to search for configuration files.

Make sure they are installed correctly to your current user (check the result of id command )

 id -a 

Also check out git config -l --show-origin to see where Git is trying to access these configuration files.

0
source

It seems you ran sudo -H and sudo changed the ownership of some files to root . Return the files:

 sudo chown -R dida /Users/dida 
0
source

Source: https://habr.com/ru/post/1270001/


All Articles