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.
lock-functionor showing your whole script or at least how you're callinglock-function.--authorhasn't always been there.gitisgitand not some wrapper? Also check there's nogit-commitin your PATH. Finally, maybe post your~/.gitconfigand.git/config.