I'm generating some patches for an opensource project and my From: line is always [email protected]. I've been manually editing the From: line to be [email protected] before running git send-email.
Example:
From fab0cf45f10686688a8138f60a09505200cbb2a4 Mon Sep 17 00:00:00 2001
From: John Doe <[email protected]>
Date: Mon, 25 Feb 2013 23:06:23 -0500
Subject: [PATCH] nand: adjust erase/read/write partition/chip size for bad blocks
After considering mvp's answer, my explicit answers are:
git am uses the From: line when setting the name of the author in the upstream repository.With git1.8.4 (July 2013), you now can set that "From field":
"
git format-patch" learned "--from[=whom]" option, which sets the "From:" header to the specified person (or the person who runs the command, if "=whom" part is missing) and move the original author information to an in-bodyFrom:header as necessary.
See commit a90804752f6ab2b911882d47fafb6c2b78f447c3:
format-patchgenerates emails with the "From" address set to the author of each patch. If you are going to send the emails, however, you would want to replace the author identity with yours (if they are not the same), and bump the author identity to an in-body header.Normally this is handled by
git-send-email, which does the transformation before sending out the emails. However, some workflows may not use send-email (e.g., imap-send, or a custom script which feeds the mbox to a non-git MUA). They could each implement this feature themselves, but getting it right is non-trivial (one must canonicalize the identities by reversing any RFC2047 encoding or RFC822 quoting of the headers, which has caused many bugs in send-email over the years).This patch takes a different approach: it teaches format-patch a "
--from" option which handles the ident check and in-body header while it is writing out the email.
It's much simpler to do at this level (because we haven't done any quoting yet), and any workflow based on format-patch can easily turn it on.Signed-off-by: Jeff King
<[email protected]>
You now can do a:
git format-path --from=...
With:
--from::
--from=<ident>::
Use
identin theFrom:header of each commit email.
If the author ident of the commit is not textually identical to the providedident, place aFrom:header in the body of the message with the original author.
If noidentis given, use the committer ident.Note that this option is only useful if you are actually sending the emails and want to identify yourself as the sender, but retain the original author (and
git amwill correctly pick up the in-body header).
Note also thatgit send-emailalready handles this transformation for you, and this option should not be used if you are feeding the result togit send-email.
Update August 2016 (3 years later)
See commit 6bc6b6c (01 Aug 2016) by Josh Triplett (joshtriplett).
(Merged by Junio C Hamano -- gitster -- in commit db40a62, 10 Aug 2016)
format-patch:format.fromgives the default for--from
This helps users who would prefer format-patch to default to
--from, and makes it easier to change the default in the future.
git config man page now includes:
format.from:Provides the default value for the
--fromoption to format-patch.
Accepts a boolean value, or a name and email address.
- If
false,format-patchdefaults to--no-from, using commit authors directly in the "From:" field of patch mails.- If
true,format-patchdefaults to--from, using your committer identity in the "From:" field of patch mails and including a "From:" field in the body of the patch mail if different.- If set to a non-boolean value, format-patch uses that value instead of your committer identity.
Defaults to
false.
Note that, with Git 2.26 (Q1 2020), spaces are better managed.
See commit f696a2b, commit ffbea18, commit f447d02, commit b6537d8 (11 Feb 2020) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit d880c3d, 17 Feb 2020)
mailinfo: be more liberal with header whitespaceSigned-off-by: Jeff King
RFC822 and friends allow arbitrary whitespace after the colon of a header and before the values.
I.e.:Subject:foo Subject: foo Subject: fooall have the subject "
foo". Butmailinforequires exactly one space.
This doesn't seem to be bothering anybody, but it is pickier than the standard specifies. And we can easily just soak up arbitrary whitespace there in our parser, so let's do so.Note that the test covers both too little and too much whitespace, but the "too much" case already works fine (because we later eat leading and trailing whitespace from the values).
With Git 2.38 (Q3 2022), "git format-patch --from=<ident>"(man) can be told to add an in-body From: line even for commits that are authored by the given <ident> with --force-in-body-from"option.
See commit d5fc07d, commit 34bc1b1, commit b84d013 (29 Aug 2022) by Junio C Hamano (gitster).
(Merged by Junio C Hamano -- gitster -- in commit 0e2a476, 09 Sep 2022)
format-patch: allow forcing the use of in-bodyFrom:header
Users may be authoring and committing their commits under the same e-mail address they use to send their patches from, in which case they shouldn't need to use the in-body
From:line in their outgoing e-mails.
At the receiving end, "git am"(man) will use the address on theFrom:header of the incoming e-mail and all should be well.Some mailing lists, however, mangle the From: address from what the original sender had; in such a situation, the user may want to add the in-body "
From:" header even for their own patches.git format-patch --[no-]force-in-body-from` was invented for such users.
git format-patch now includes in its man page:
--[no-]force-in-body-fromWith the e-mail sender specified via the
--fromoption, by default, an in-body "From:" to identify the real author of the commit is added at the top of the commit log message if the sender is different from the author.With this option, the in-body "
From:" is added even when the sender and the author have the same name and address, which may help if the mailing list software mangles the sender's identity.
With Git 2.47 (Q4 2024), batch 9, "git send-email"(man) learned --translate-aliases option that reads addresses from the standard input and emits the result of applying aliases on them to the standard output.
See commit c038a6f, commit bbc04b0, commit 16d89aa (13 Aug 2024) by Jacob Keller (jacob-keller).
(Merged by Junio C Hamano -- gitster -- in commit 3dd2a2f, 26 Aug 2024)
send-email: teach git send-email option to translate aliasesSigned-off-by: Jacob Keller
git send-email(man) has support for converting shorthand alias names to canonical email addresses via the alias file.
It supports a wide variety of alias file formats based on popular email program file formats.Other programs, such as
b4, would like the ability to convert aliases in the same way asgit send-emailwithout needing to re-implement the logic for understanding the many file formats.Teach
git send-emaila new option,--translate-aliases, which will enable this functionality.
Similar to--dump-aliases, this option works like a new mode of operation forgit send-email.When run with
--translate-aliases,git send-emailreads from standard input and converts any provided alias into its canonical name and email according to the alias file.
Each expanded name and address is printed to standard output, one per line.
git send-email now includes in its man page:
--translate-aliasesInstead of the normal operation, read from standard input and interpret each line as an email alias. Translate it according to the configured alias file(s). Output each translated name and email address to standard output, one per line. See 'sendemail.aliasFile' for more information about aliases.
Setting your git identity should be enough:
git config --global user.email [email protected]
git config --global user.name "John Doe"
You can also set your identity per git repository: run these commands inside that git repostory and simply omit --global flag.
You probably should not use [email protected] because if someone git am it, this commit will have not your identity.
Probably the only reason to do that is to avoid spam to your primary address - but I think you will get it anyway as soon as it becomes public.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With