This is definitely not best practice, but on some servers I have some server configuration in Git and I deploy and update them manually. Git is used only as versioning system for configuration and not automatic provisioning.
In theory things should be pretty straight forward, but there are two main issue with this approach, both caused by the fact that you have to use git after you switch to root account (
- you loose you ssh key chain and you can not pull/push changes
- if you commit changes, your Git name and email are empty and using
git configit's not OK since multiple users might do the same thing
It's possible to fix this using sudo by using something like this:
sudo -Es GIT_AUTHOR_NAME=Your\ Name GIT_COMMITTER_NAME=Your\ Name GIT_COMMITTER_EMAILfirstname.lastname@example.org GIT_AUTHOR_EMAILemail@example.com su
I added an alias for this and whenever you use the alias, you will forward your ssh key chain and set Git username and password by setting temporary environment variables. It's multi user friendly, so multiple admins can use this to do changes as root and commits author name and ssh keys will be set for each individual.