Allowing "/" in the name of a git remote is a strange choice
- From
Per Cederqvist <ceder@lysator.liu.se>
- Date
- Jul 3, 2025, 19:33 UTC
- Message-ID
- <CAHx6-Um1dq0xJ-RkW+qXe=sEa6JGViSJxjzNw56u55DHLYoT2Q@mail.gmail.com>
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:
Show 7 quoted lines
> $ git fetch --all > Fetching origin > From $PRIVATE_URL > + 4e31956300f...30e26ebbb19 chat/master -> origin/chat/master (forced update) > Fetching origin/chat > From $PRIVATE_URL > + 30e26ebbb19...4e31956300f master -> origin/chat/master (forced update)
Every time I run "git fetch --all" git updates the origin/chat/master ref twice.
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.
/ceder