Reputation: 3252
I wrote the following bash function which should create a commit with my username hardcoded. Yes I know about git config
, this is just a minimal example to demonstrate the problem I'm having.
# lib.sh
function lock-commit() {
local commit_author="Varun Madiath <[email protected]>"
git commit --author="${commit_author}" "$@"
}
However when I run this, it gives me the error below. Running the command on the command line directly does not result in the error.
[vmadiath@magma ac-test]$ source lib.sh
[vmadiath@magma ac-test]$ lock-commit -m "test"
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <[email protected]>) not allowed
Given that I'm explicitly passing the author, I shouldn't need to set the user.email
and user.name
config settings.
Any idea why this is happening, and how I can correct this behaviour.
Upvotes: 2
Views: 112
Reputation: 20620
Git records two details for each commit: the author (which is what you're overriding) and the committer (which is what it's looking for in your settings).
This allows one user to commit changes on behalf of another, while recording details of both users in the repository.
Upvotes: 1