I have the problem, that we login to the systems as our own users johndoe and then have to do a sudo su - root to be able to do administrative tasks. We have the system config files in a git repository (which makes everything better). But now I lose the settings in the user's (johndoe) /home/johndoe/.gitconfig file.I tried to set the $GIT_CONFIGvariable which works, but this is only for setting the repo configuration, not the global one and therefore the for me important variables won't be set:$ sudo su - rootHello johndoe. Switching your .gitconfig to /home/johndoe/.gitconfig# git config --get user.nameJohn Doe# git config --get user.emailjohndoe@somefirm.somewhere# git config --global --get user.name# git config --global --get user.email#This is the trick I tried:$ cat .bashrc--- snip ---# load git config of userLOGINUSER=$(who am i|awk '{print $1}')if [ $LOGINUSER != root ]; then    GITCFGFILE=/home/$LOGINUSER/.gitconfig    if [ -f $GITCFGFILE ]; then        echo Hello $LOGINUSER. Switching your .gitconfig to $GITCFGFILE        export GIT_CONFIG=$GITCFGFILE    fifiIs there a way to set the path for the global git configuration?
Is it possible to set the users .gitconfig (for git config --global) dynamically?
bash;sudo;git;su
To answer my Question: NoThis is the solution i ended up with:I added a file /etc/profile.d/gitsetup.sh with the following content:[ -z $PS1 ] && return[ -z $BASH_VERSION -o -z $PS1 ] && returnCFGFILE=/home/$(who am i|awk '{ print $1 }')/.gitconfig[ $USER == root -a -f $CFGFILE -a -n $CFGFILE ] && cat $CFGFILE > $HOME/.gitconfigIt tests on line one and two for an interactive shell, reads the source .gitconfig path on line three and then replaces the roots config file if the source file exists.