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

Re: .gitmodules containing SSH clone URLs should fall back to HTTPS when SSH key is not valid/existent

From
Jeff King <peff@peff.net>
Date
May 29, 2014, 23:56 UTC
Message-ID
<20140529235643.GB28683@sigill.intra.peff.net>
In-Reply-To
<CA+OJ3utofb+od5uct4HF1yoQGfWgX7YTn4hPChDpC7LTFVJDYQ@mail.gmail.com>
On Thu, May 29, 2014 at 04:12:38PM -0700, Jonathan Leonard wrote:
Show 10 quoted lines
> We are using GitHub.
> [...]
> > But why is https special? Why not fall back to the git
> > protocol? Or http? (And no: I'm not serious here ;-)
> >
> 
> HTTPS isn't special except in that it is the least privileged
> transport type (and thus should be the last resort). Whether to
> fallback to git:// from ssh:// or vice versa is inconsequential to
> this request.

That's not quite true. git:// is the least privileged transport, as it always anonymous and read-only (there ways to allow insecure pushes over it, but GitHub does not enable them). Https is actually the most flexible protocol, in that the same URL works of the box for both logged-in and anonymous users (the latter assuming the repo is publicly available). The server only prompts for credentials if necessary.

For that reason, it's a good choice for things like submodule URLs baked into .gitmodules files.

The reasons not to are:
  1. It isn't _quite_ as efficient or robust as the regular git
     protocol, though in practice it's generally not a big deal.
  2. Pushers may prefer to authenticate with ssh keys (e.g., because
     they run ssh agent). I hope with modern credential helpers that
     logging in via http should not be a pain, either, though.
Show 10 quoted lines
> > After the first failed clone of the submodule at via SSH the
> > developer could also just do a
> >
> >    git config submodule.<name>.url https://host/repo
> >
> > and override the URL from .gitmodules.
>
> Yes, this would work. But it would be a painful manual step which we
> would not want to force on ordinary users (and would not want to
> experience ourselves either).

Using insteadOf of in your global ~/.gitconfig would make this a one-liner per-user. So one option would be to reverse things. Put "https" URLs into the .gitmodules file, so most people have to do nothing, and then developers who really want to do git-over-ssh can do a one-time:

  git config --global url.git@github.com:.insteadOf https://github.com/
-Peff
Previous: Jonathan LeonardNext: Chris Packham
Message 5 of 6 in “.gitmodules containing SSH clone URLs should fall back to HTTPS when SSH key is not valid/existent”
  1. Jonathan LeonardMay 29, 2014
  2. Jens LehmannMay 29, 2014
  3. Junio C HamanoMay 29, 2014
  4. Jonathan LeonardMay 29, 2014
  5. Jeff KingMay 29, 2014
  6. Chris PackhamMay 30, 2014

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.