Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which characters are illegal within a git remote name?

Tags:

git

git-remote

Which characters are illegal within a git remote name ?

I didn't found it the git documentation.

like image 697
yacine Avatar asked Jan 04 '17 10:01

yacine


People also ask

What will be the remote name git?

origin = the default name of the remote repository on GitHub corresponding to the repo you're currently in on your machine. master = the default name of the initial branch of a repository. So, "origin master" is the default branch of your repository on GitHub.

What should GitHub remote name?

The remote name is a short-hand label for a remote repository. "origin" is the conventional default name for the first remote and is usually where you push to when you don't specify a remote for git. You can set up more than one remote for your local repo and you use the remote name when pushing to them.

What is the remote name of a repository?

If you clone a repository, the command automatically adds that remote repository under the name “origin”. So, git fetch origin fetches any new work that has been pushed to that server since you cloned (or last fetched from) it.

What is remote name and branch name in git?

REMOTE-NAME is the name of your remote repository. For example: origin. BRANCH-NAME is the name of your branch. For example: develop.


1 Answers

I didn't find anything in the documentation, either. So let's take a look at the source.

When you try to add a remote with an invalid name or rename a remote to an invalid name, you'll get an error message like

fatal: 'foo@{bar' is not a valid remote name

So let's search the Git source for that.

We see that Git goes about this a bit backwards: It tests (here for adding, here for renaming (mv)) whether refs/heads/test:refs/remotes/<the remote name>/test is a valid fetch reference, as determined by valid_fetch_refspec(<the ref name>), which in turn calls parse_refspec_internal(...).

The latter does many checks that will most of the time pass anyway due to the majority of the input being given in our case, but it will also call check_refname_format(...) on the right-hand side (i.e. the refs/remotes/<the remote name>/test part if the splitting at : went alright).

I guess this means that the characters and character sequences disallowed for branches and tags are also forbidden for remote short names.

like image 53
das-g Avatar answered Oct 11 '22 07:10

das-g