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>"
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 firstname.lastname@example.org
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
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. You can go this via the command line too, using the
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.