3

I'm using git to track changes to a series of system configuration file on a server. These files are owned by the root account (and for various internal enterprise-y reasons, root is the only account on this box).

There is a central git server, which all changes made on this system are being pushed to.

What I'm trying to do is suppress the warning that git throws because there isn't a user account set. What we do is, anyone changing a file under git control simply sets the --author option when they do the commit - however, git still complains that the user information isn't set.

For detail, the exact message is:

[root@server ~]# git commit --author "Karunamon <[email protected]>"
[master 491d9f8] File updated
 Author: Karunamon <[email protected]>
 Committer: root <root@server>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email [email protected]

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+), 1 deletion(-)

So basically, this is a twofold question:

First, Is there a way to squelch this warning message? Setting the config variable is going to end in confusion since there will be a number of people accessing this same repository on this server under the root account.

I did try using the environment variables (GIT_AUTHOR_EMAIL, GIT_AUTHOR_NAME, etc), but the same message comes up.

Second, Is there a better way (short of some horrid hack involving an .rc file and asking on login) to set the user name and email so that my users don't have to add an --author flag to every commit?

The environment variable option would have been perfect - I could just have my users export the variables on login and then they're good until next connect.. but git still whines.

2 Answers 2

3

Try

git -c user.email="Karunamon <[email protected]>" commit

This will override the config setting when executing that command.

You can then make an git alias / wrapper that inserts that value from a local env variable on execution.

Sign up to request clarification or add additional context in comments.

3 Comments

That fails completely: # git commit -c user.email="Karunamon <[email protected]>" fatal: could not lookup commit user.email=Karunamon <[email protected]> - It's also even longer than the author flag :(
@MikeyT.K.: Sorry; the word commit must come last. Unlike --author, this should suppress the warning. (I haven't tried it)
You will need to specify user.name as well.
1
git -c user.email="[email protected]" -c user.name="Karunamon" commit

That one works for me. It requires user.name as well.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.