Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does `git` name only as "origin" any remote upon cloning?

Tags:

git

Does Git only use the remote name "origin" for a repository which was created by cloning?

For example, say I create a repository, placed it on a remote, and try to clone it again into the same directory, which one would Git name origin?

like image 488
vfclists Avatar asked Sep 01 '25 04:09

vfclists


2 Answers

2010: origin is the default name used by git clone, but you can use any other name when cloning:

--origin <name>
-o <name>

Instead of using the remote name origin to keep track of the upstream repository, use <name>.

If you don't, any time you clone a repo, that remote repo will be referenced by the default name origin.


With Git 2.30 (Q1 2021, 11 years later), you now have the option clone.defaultRemoteName.

like image 118
VonC Avatar answered Sep 02 '25 19:09

VonC


If origin doesn't fit you, you can always rename it to a more appropriate name:

git remote rename <old> <new>

See description of git remote.

like image 33
eckes Avatar answered Sep 02 '25 18:09

eckes