On Thu, Nov 1, 2018 at 3:42 PM Nicolas Mailhot
<nicolas.mail...@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 via email to