git commit --author doesn't work when global not set
What if you set the git config info just for the current repository?
git config user.email "[email protected]"
git config user.name "Your Name"
EDIT Based on OP comment a possible solution is:
GIT_AUTHOR_EMAIL="[email protected]" && GIT_AUTHOR_NAME="Your Name" && git commit
First, With Git 2.29 (Q4 2020), the error message is clearer.
See commit 9ed104e (21 Aug 2020) by Junio C Hamano (gitster
).
(Merged by Junio C Hamano -- gitster
-- in commit e9bd00a, 31 Aug 2020)
ident
: say whose identity is missing when givinguser.name
hint
If
user.name
anduser.email
have not been configured and the user invokes:git commit --author=...
without specifying the committer identity, then Git errors out with a message asking the user to configure
user.name
anduser.email
but doesn't tell the user which attribution was missing.This can be confusing for a user new to Git who isn't aware of the distinction between user, author, and committer.
Give such users a bit more help by extending the error message to also say which attribution is expected.
The error message will clearly state:
Author identity unknown
# or
Committer identity unknown
Second, from OP's comment:
Other people use the machine and the same repo. I guess I could set up the git config and then remove the configuration when I'm done
You can wrap the git command and forcing each used to identify themselves (once per shell session).
See "Best pracitces for multi-developer Git for single user application" and my project VonC/gitw
.