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

Re: Allowing "/" in the name of a git remote is a strange choice

From
Per Cederqvist <ceder@lysator.liu.se>
Date
Jul 4, 2025, 06:42 UTC
Message-ID
<CAHx6-UmL7qHf-0SoD1qrOKbWK5JjuESJaZdQK_rjy66RrYg0Xg@mail.gmail.com>
In-Reply-To
<xmqqikk8bltr.fsf@gitster.g>
On Fri, Jul 4, 2025 at 6:51 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
>
> Per Cederqvist <ceder@lysator.liu.se> writes:
>
> > Today I realized that git accepts "/" in a remote name.
> >
> > This can lead to problems. I have a repository that contains a branch
> > called "master" and another called "chat/master". Just for fun, I
> > added a second remote in this repository and named it
> > "origin/chat".
> >
> > Now, does "refs/remotes/origin/chat/master" refer to the branch
> > "chat/master" from "origin", or the branch "master" from
> > "origin/chat"? Git seems to think it refers to both:
>
> That would have been a fun experiment ;-)

It was. Luckily I figured this out while trying to deduce the allowed format of a remote name by reading the source code, not while trying to understand confusing behaviour from git.

Show 12 quoted lines
> > If it was up to me, I'd add a check to valid_remote_name() to ensure
> > the name doesn't contain any "/" character.  I doubt it is used often.
>
> If your remote-naming discipline is to always use two-levels
> (e.g. origin/chat, origin/chien, origin/lapin but never origin or
> origin/chat/blanc mixed in), then there is no confusion.
>
> It becomes only confusing if you mix origin and origin/chat.
>
> So it is not like we can just forbid '/' retroactively and expect no
> repercussions, especially given that I hear there are more than a
> few thousands of existing Git users in the world.

I wonder how many use "/" in a remote name, though. My guess is very few.

If you want to do anything about this, there are a few possible ways:
- forbid "/", but add a setting that allows it. Note that even if you forbid
  "/", existing clones will continue to work. It is only when you add a
  new remote that the name is checked.
- require that the number of "/" character in a remote is equal for all
   remotes in a particular clone
- deperecate "/" and start warning about it now, and forbid it after a
suitable period
    /ceder
Previous: Junio C HamanoNext: Jeff King
Message 7 of 18 in “Allowing "/" in the name of a git remote is a strange choice”
  1. Per CederqvistJul 3, 2025
  2. Junio C HamanoJul 4, 2025
  3. Patrick SteinhardtJul 4, 2025
  4. Lidong YanJul 4, 2025
  5. Lidong YanJul 4, 2025
  6. Junio C HamanoJul 4, 2025
  7. Per CederqvistJul 4, 2025
  8. Jeff KingJul 5, 2025
  9. remote: detect collisions in remote namesJeff King, Jul 5, 2025
  10. Patrick SteinhardtJul 7, 2025
  11. Jeff KingJul 7, 2025
  12. Junio C HamanoJul 7, 2025
  13. Jeff KingJul 8, 2025
  14. Jeff KingJul 8, 2025
  15. Junio C HamanoJul 8, 2025
  16. Jeff KingJul 9, 2025
  17. Junio C HamanoJul 7, 2025
  18. Raymond E. PascoJul 9, 2025

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.