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 more as versioning system and less for deployment.
There are two main issue with this approach once 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 suI 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 send temporary environment variables.