Web lists-archives.com

RE: [RFE] Please add name and email to git credentials




On November 1, 2018 10:13 AM, Christian Couder wrote:
> Sent: > To: nicolas.mailhot@xxxxxxxxxxx
> Cc: git <git@xxxxxxxxxxxxxxx>
> Subject: Re: [RFE] Please add name and email to git credentials
> 
> On Thu, Nov 1, 2018 at 2:31 PM Nicolas Mailhot
> <nicolas.mailhot@xxxxxxxxxxx> wrote:
> >
> > Le jeudi 01 novembre 2018 à 12:22 +0100, Ævar Arnfjörð Bjarmason a
> > écrit :
> > >
> > > Where would we get an E-Mail to lookup to pass to the helper? Are
> > > you just asking that the helper git the result of $(git config
> > > user.name && git config user.email)? If so why can't it just look
> > > this up itself?
> >
> > So, just in case it was not clear enough, allow things in .gitconfig
> > like
> >
> > [credential "https://pkgs.fedoraproject.org/";]
> > username = doe4ever
> > name = John Doe
> > email = doe4ever@xxxxxxxxxxxxxxxxx
> > [credential "https://gitlab.corp.com/";] username = jdoe56874 name =
> > John Doe, Snr Engineer email = john.doe@xxxxxxxx
> >
> > Instead of just
> >
> > [user]
> > name = John Doe
> > email =  john.doe@xxxxxxxx
> > [credential "https://pkgs.fedoraproject.org/";]
> > username = doe4ever
> > [credential "https://gitlab.corp.com/";] username = jdoe56874
> >
> > and drat, I've commited to XXX with the wrong name/email again
> 
> How can Git know when you commit where you will want to push the
> commit afterwards?
> 
> What if you want to push the same commit to 2 different places that need
> different credentials?

Agree. You are asking git to change history depending on where pushes are done. Applying a legacy VCS paradigm here? Git has a global view of history. It must be the same everywhere, so if you push to two different places, the history must be the same, because those two places may in turn push to another shared repo. Then who is the authority?

What I have managed to do is to associated name and email with config --local so that it binds to the clone and overrides your --global setting. I can have different identities based on what clone I am working on, but once history is created, that's it. If I push from one clone to another, the identity of the clone where I did my first commit is what the second clone sees.

Hope this helps.
Randall

-- Brief whoami:
 NonStop developer since approximately 211288444200000000
 UNIX developer since approximately 421664400
-- In my real life, I talk too much.