git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 13, 2020, 05:32 UTC
Message-ID
<xmqqsgailmhu.fsf@gitster.c.googlers.com>
In-Reply-To
<CABmmNJMzs=BOYEv_pUaA3NbNkn_HhyOj_VoYeWSKzz138OCZkQ@mail.gmail.com>
Deepak Patankar <patankardeepak04@gmail.com> writes:
Show 17 quoted lines
> 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.

Previous: Deepak Patankar
Message 4 of 4 in “How to Verify the Git Credentials supplied by the User”
  1. Deepak PatankarOct 12, 2020
  2. Junio C HamanoOct 12, 2020
  3. Deepak PatankarOct 13, 2020
  4. Junio C HamanoOct 13, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.