I am trying to commit to a project on github.com 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 <MyNameEmail@email.com>"
and I received the message:
Committer: unknown <WorkEmail@workemail.net>
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 you@example.com
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 github.com project. Is there anything else I can try and is it even possible?
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 user.name "Your Name"
git config user.email "Your email"
Notice the absence of the --global
option. This will set the configuration in this repository only.
Alternatively, you can do this for only a single command, using the -c
option:
git -c "user.name=Your Name" -c "user.email=Your email" commit ...
But I think it's better to just use the config options above.