git

git commit --author doesn't work when global not set


working on a lab machine which has a shared login. don't want to set global git config parameters.

git commit --author="username <email>" 

This used to work on older git versions. now it produces this error:

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  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: unable to auto-detect email address (got 'blah@blah.(none)')

Any thoughts?


Solution

  • What if you set the git config info just for the current repository?

      git config user.email "you@example.com"
      git config user.name "Your Name"
    

    EDIT Based on OP comment a possible solution is:

    GIT_AUTHOR_EMAIL="you@email.com" GIT_AUTHOR_NAME="Your Name" git commit