Reputation: 9863
Is there a possibility of setting multiple user emails?
I'm trying to associate all future commits with several emails so that, for example, they could be found in GitHub/GitLab/(etc) UI by either of the emails, and also an existing GPG signature would still be applicable to that commit. Can this be done?
Let me also specify what I don't mean:
user.email
and global user.email
;Basically, I want to change this:
… into something like this:
Upvotes: 2
Views: 1738
Reputation: 60255
Is there a possibility of setting multiple user emails? I'm trying to associate all future commits with several emails
Yes, Git's got a facility for this, the mailmap file. Its default location is as a committed .mailmap
file, but you can configure it to be wherever you want, see git shortlog
and git check-mailmap
for the full details. So if you've got multiple emails, pick a primary one, write
Dima Parzhitsky <[email protected]> <[email protected]> <etc…>
to .mailmap
and git will associate your primary name and email with all those email addresses.
so that, for example, they could be found in GitHub/GitLab/(etc) UI by either of the emails
There's no guarantee that every web frontend implements all of Git. The ones that don't implement Git's email mapping won't make the associations you list here. Git itself, though, will.
Upvotes: 3
Reputation: 76439
It isn't possible to specify multiple email addresses for an author or committer in a single commit. The syntax you've proposed may (or may not) be accepted by Git, but it does not represent multiple email addresses. Since it does not match the production in RFC 5322, it fails to represent an email address at all. A real email address is permitted to contain spaces, but they must be quoted; this is just malformed.
GitHub and GitLab will not consider this syntax to match any valid email address at all because the part between the email address is supposed to represent exactly one email address according to the production in RFC 5322. Consequently, any such commit you make won't be associated with your account. Even if this syntax is accepted now, it may be rejected by Git or other tools in the future.
Upvotes: 0
Reputation: 487963
The short answer is no: a commit is supposed to have exactly one author, and one committer.
There apparently are some commits in some existing repositories that have more than one author, so git fsck
diagnostics call this out as a separate error, which can be configured to be a warning instead of an error. This means that the checks for incoming commits (from git push
operations to servers) can also call them out as warnings instead of errors.
If you were to make this a warning in every system you use—including all the hosting systems you use—you would gain the ability to create and transfer such commits. It does not seem like a particularly good plan overall, though.
Upvotes: 1