克隆时`git` 是否仅将任何远程命名为“起源”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2570899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:13:19  来源:igfitidea点击:

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

git

提问by vfclists

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

Git 是否只对通过克隆创建的存储库使用远程名称“origin”?

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?

例如,假设我创建了一个存储库,将它放在一个遥控器上,然后尝试再次将其克隆到同一目录中,那么 Git 会命名为 origin 吗?

回答by VonC

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

origin 是 使用的默认名称git clone,但您可以在克隆时使用任何其他名称:

--origin <name>
-o <name>

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

不要使用远程名称origin来跟踪上游存储库,而是使用<name>.

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

如果不这样做,则任何时候克隆存储库时,都会使用默认名称引用该远程存储库origin

回答by eckes

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

如果origin不适合您,您可以随时将其重命名为更合适的名称:

git remote rename <old> <new>

See description of git remote.

参见git remote 的描述。