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

Multiple urls for remotes?

From
Mike Hommey <mh@glandium.org>
Date
Jun 26, 2019, 23:52 UTC
Message-ID
<20190626235247.nhw45da52rz46mad@glandium.org>
Hi,

I was surprised to figure out that urls/pushurls set up for remotes can be set multiple times, and that those urls end up being used sequentially.

Sadly, this has the side effect that one cannot override the config from the command line, as the url is then added as an extra url, which is tried after the already configured one.

e.g.
    git -c remote.origin.url=/tmp/foo push origin

will keep pushing to wherever the .git/config's remote.origin.url points to.

With all the configuration items that work this way, it's actually kind of sad that it's not possible to force the value from the command line to override anything that is set in the configuration.

It's worth noting that the documentation for -c says:
    Pass a configuration parameter to the command. The value given will
    override values from configuration files.

... which implies -c remote.origin.url=/tmp/foo should, in fact, replace any other value already set.

Coming back to the fact that remote.origin.url and remote.origin.pushurl can actually have multiple values, it's also worth noting that none of the git-config, git-fetch or git-push documentation seem to say anything about the fact there can be multiple values.

The git-config documentation says:
   remote.<name>.url
       The URL of a remote repository. See git-fetch(1) or git-push(1).
   remote.<name>.pushurl
       The push URL of a remote repository. See git-push(1).
The git-fetch and git-push documentations always talk about _the_ URL.

The only thing that seems to be talking about this is the documentation for git-remote, which has --add for set-url. There doesn't seem to be any documentation about what conditions are required for the non-primary URL to be used.

Mike
Next: brian m. carlson
Message 1 of 2 in “Multiple urls for remotes?”
  1. Mike HommeyJun 26, 2019
  2. brian m. carlsonJun 27, 2019

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.