git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: nicolas.mailhot@gmail.com
Cc: git <git@vger.kernel.org>
Subject: Re: [RFE] Please add name and email to git credentials
Date: Fri, 2 Nov 2018 09:27:36 +0100	[thread overview]
Message-ID: <CAP8UFD0DHGShwo=DnwbSHz3nvRMF9P4GegEzC27uwHLXQ=A4Zw@mail.gmail.com> (raw)
In-Reply-To: <62bf61555a6c2789e959e4f085bfedf28b60f268.camel@laposte.net>

On Thu, Nov 1, 2018 at 3:42 PM Nicolas Mailhot
<nicolas.mailhot@gmail.com> wrote:
>
> Le jeudi 01 novembre 2018 à 15:13 +0100, Christian Couder a écrit :
> >
> > How can Git know when you commit where you will want to push the
> > commit afterwards?
>
> You have an url in the repo config. of course you can change it between
> the commit and the push, but that's not the general case.

If I did a `git init`, then I have no url in the repo config. Also if
I cloned from a repo that has a different URL than the sites I have
credentials for, then how should git use the URL in the repo config?

> Nowadays, most git projects have a preferred git hosting, and your
> name/email with the project match the credentials you use to push
> (otherwise things like gitlab/github issues trackers would not work at
> all).

I think you are talking about a special need that you have, but it's
not the same for everyone. For example I always use my real name
"Christian Couder", and when my email changes, I would like it to
change everywhere, so support for .mailmap files in GitHub and GitLab
for example would be much more important for me than what you suggest.

> > What if you want to push the same commit to 2 different places that
> > need different credentials?
>
> Then you do not use git credentials and have to configure all by hand.
> Which will usually be a major error-prone PITA, so you’ll end up pushing
> to the system that matches the ID you want to se in git logs, and then
> push from this system to others.

You could have no user.name and user.email configured in your global
config, and a script that configures those in the local config
depending on remote.origin.url. So when you commit in a repo, Git will
fail if user.name and user.email are not already configured in the
repo. It will tell you to configure those, then you just have to run
your script to get those configured locally, and you are good to go.

Another more flexible possibility is what Ævar suggest with
conditional includes in the config.

  reply	other threads:[~2018-11-02  8:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01  9:59 [RFE] Please add name and email to git credentials Nicolas Mailhot
2018-11-01 11:22 ` Ævar Arnfjörð Bjarmason
2018-11-01 12:34   ` Nicolas Mailhot
2018-11-01 13:15     ` Ævar Arnfjörð Bjarmason
2018-11-01 14:13     ` Christian Couder
2018-11-01 14:32       ` Randall S. Becker
2018-11-01 14:42       ` Nicolas Mailhot
2018-11-02  8:27         ` Christian Couder [this message]
2018-11-02  8:57           ` Nicolas Mailhot
2018-11-02 16:51             ` Jeff King
2018-11-02 17:32               ` Nicolas Mailhot
2018-11-02 17:56                 ` Jeff King
2018-11-01 11:32 ` Nicolas Mailhot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP8UFD0DHGShwo=DnwbSHz3nvRMF9P4GegEzC27uwHLXQ=A4Zw@mail.gmail.com' \
    --to=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=nicolas.mailhot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).