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

Re: Authentication with e-mail address as user name for HTTPS remote

From
Jeff King <peff@peff.net>
Date
Aug 31, 2013, 08:09 UTC
Message-ID
<20130831080946.GB21744@sigill.intra.peff.net>
In-Reply-To
<CADZGgi9-nLpcaHQOevBnY9HZtkLD6Zn=gCZq8u5yefPV7gYaTg@mail.gmail.com>
On Sat, Aug 31, 2013 at 08:52:06AM +0200, Patrick Atoon wrote:
Show 10 quoted lines
> Here is what happens. First try cloning without specifying the user name:
> 
> ---8<-------------------------------------------------------
> $ git clone https://git.server.com/git/test.git
> Initialized empty Git repository in /tmp/git/test/.git/
> error: The requested URL returned error: 401 Authorization Required
> while accessing
> https://git.server.com/git/test.git/nfo/refs
> 
> fatal: HTTP request failed
That should be prompting you. What version of git are you using?
> I couldn't find a "--username" flag or something similar for the git
> command, so my next try was to incorporate the user name in the URL,
> basic auth style.
Yes, that's the correct way to do it from the command line.

If you are running v1.7.9 and later, you can also put this in your config:

  [credential "https://git.server.com"]
    username = user.email@emaildomain.com
to automatically use that username for the particular domain.
> https://user.email@emaildomain.com@git.server.com/git/test.git
> 
> Note the double "@" there, it is bound to cause trouble.
Yes. You probably want to escape it like:
  https://user.email%40emaildomain.com@git.server.com/git/test.git

In theory we could parse from the right-hand side of the hostname and realize that only the right-most "@" is the username separator (under the assumption that hostnames can never contain an "@"). I don't know if that would violate the standard or not. However, it is not even git that does the actual parsing in this case, but rather libcurl.

-Peff
Previous: Patrick Atoon
Message 2 of 2 in “Authentication with e-mail address as user name for HTTPS remote”
  1. Patrick AtoonAug 31, 2013
  2. Jeff KingAug 31, 2013

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.