I'm creating a web-based PHP client for managing site content with Git. I want to associate commits with the various people that are logged in the admin panel. I know I can do this with:
git commit --message="foo" --author="John Doe <[email protected]>"
However, you can also push to a remote repository (in my case, hosted on GitHub) through the admin panel as well. I can't seem to set the name/email of the committer with something like:
git push origin master --author="John Doe <[email protected]>"
...so in GitHub, the author is John Doe, but the committer is me:

I noticed that the committer is based on the Git config. So I can change it and get the correct result:

My question is, do I need to do this:
git config user.name {{ panel user name }}
git config user.email {{ panel user email }}
git push origin master
...every time someone pushes to the repo, or there's a better way? I like how you can specify the author in git commit. Can this somehow be achieved with git push as well?
The author and committer are actually stored as part of the commit object itself, when it is created. So if you want to customize the author and committer names, you need to do it when running git commit. According to the official documentation, you can set both the author and committer information with these four environment variables:
GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL
GIT_COMMITTER_NAME
GIT_COMMITTER_EMAIL
Or alternatively, you can pass custom temporary configuration options to git using the -c option.
git -c user.name="John Doe" -c user.email="[email protected]" commit ...
I believe it's more typical to use the environment variables from a script, but I'm not sure why (or, really, if) that is the case.
Note that the push command simply sends existing commit objects, including their stored author and committer information, up to the server. You can't change the author or committer while pushing, at least not with standard git as far as I know. I'm not sure how you're managing to pass an --author option to git push, but it's not listed in the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With