Subject: Re: How to Verify the Git Credentials supplied by the User

From: Junio C Hamano <[email-masked]>
Date: Mon, 12 Oct 2020 22:32:13 -0700

Deepak Patankar <[email-masked]> writes:

> I can use the "ls-remote", "push --dry-run" command you suggested, but
> I have a use case which I don't know how to solve.
> The above commands require a repository. In our application, the user
> can give the following details
>
> Git Details:
>    Account URL:  https://github.com/OpenPrinting
>    UserName: deepakpatankar
>    password: ***********
>
> In this case, we don't know the repo name. At this step, I just know
> the account and the credentials of the user, later on
> the user will provide me with the repo name to which he wants to sync his file.
>
> Since I don't know the repository, I cannot do "git fetch" or "git
> push --dry-run". Can I check this credentials with some
> logic or git commands?

You'd have to go outside Git, as our transport layer is only about
talking with existing repositories.  You cannot even create a new 
repository using Git native methods.

You may need to find a method that works with GitHub account (note
that I am not even using the word repository here, instead saying
"account") and such a method would likely have to involve GitHub
specific API, but it probably would not work with other hosting
providers.

I also would imagine that even at GitHub, one may want to use
different authentication info depending on which repository one
accesses, so the "there is a single User with a password at this
hosting site" data model might turn out to be insufficient, but
that is outside the scope of Git proper.