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