We use git to track changes in /etc/
on our servers.
Administrators work as root when changing files in /etc/, and thus their commits have author
root <root@machinename>
This is not very satisfying since you cannot see which admin actually did the change.
What can we do to get the real admin names in the git log? I don't think that keeping a local clone of the repository is feasible since we often change interatively until something works, and a change-commit-push-seeError-repeat cycle would not help here.
Best Answer
The git author and committer name can be influenced with the environment variables
GIT_COMMITTER_NAME
,GIT_COMMITTER_EMAIL
,GIT_AUTHOR_NAME
andGIT_AUTHOR_EMAIL
.Now the trick is to submit those variables to the remote server when connecting through SSH:
Define and export the variables in your
~/.bashrc
file:Automatically send them with a SSH connection by adjusting
~/.ssh/config
:LANG
andLC_*
are not neccesary, but Debian has then in their default ssh_config, so I thought I should submit them, tooOn the remote server, adjust the sshd configuration in
/etc/ssh/sshd_config
to acceptGIT_*
environment variables:Voila - a
git commit
as root in/etc/
leads to:In case serverfault faults some time in the future: http://cweiske.de/tagebuch/carry-git-settings.htm