Pred Pred - 1 year ago 183
Git Question

Override configured user for a single git commit

I am trying to commit to a project on from my work laptop, which is already configured for the company git server. Is there a way to commit specifying different author credentials, possible using a different configuration file or orther command line switches?

I've tried using

--author="My Name <>"

and I received the message:

Committer: unknown <>
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 "Your Name"
git config --global

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

git commit --amend --reset-author

but it still didn't update my username for committing to the project. Is there anything else I can try and is it even possible?

Answer Source

First, the author is not necessarily the same as the committer. Git tracks both.

To set what name to use for just this repository, you could do:

git config "Your Name"
git config "Your email"

Notice the absence of the --global option. This will set the configuration in this repository only. You can go this via the command line too, using the -c option:

git -c " Name" -c " email" commit ...

But I think it's better to just use the config options above.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download