Re: "commit --author=..." does not work if global email and name is not set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Piotr Krukowiecki <piotr.krukowiecki@xxxxxxxxx> writes:

> Hi,
>
> I have a repo downloaded on machines which do automatic tests.
> Sometimes I want to make a quick fix there and push back to origin.
> Reading git-commit docs I had impression that I can use "--author=me"
> and it will work. But it requires setting global user name and email:
>
> ========================================================
> $ git commit --author=pkruk
>
> *** Please tell me who you are.
>
> Run
>
>   git config --global user.email "you@xxxxxxxxxxx"
>   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 'some@default.(none)')
> ========================================================
>
> I do not want to set the default name/email, because I want commits to
> have real names, and not some "automatic test account" info. For
> pushing back to origin I already have to use a read-write SSH key, but
> lack of default name/email would prevent accidental commits (people
> WILL forget to use --author ...).
>
> Do you think changing git to not require default name/email if
> "--author" is specified is possible (and hopefully easy and quick to
> implement ;))?

As Junio said, the "--author=<author name and email>" sets the author
identity, but not the committer identity; you can work around the issue
with "git -c user.name=me -c user.email=me@xxxxxxxx".

In Git the commit stories both the author and the committer.  The author
is the person who made the changes, the committer is the person who
entered the changes into repository (created a commit object).  You
might want to enter into your repository changes made by somebody else
(that you for example got as a patch): that is what --author is for.

Better though is to focus on what you want, namely to prevent accidental
commits without specified author, instead of how you want to achieve it,
i.e. using --author to provide both author and committer identity (the
XY problem).  On that machine with "automatic test account" set up
pre-commit or commit-msg hook that fails if the GIT_AUTHOR_IDENT
environment variable is not the "automatic test account".

Hope that helps,
--
Jakub Narębski




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux