克隆和复制 git repo 有什么区别? [英] What's the difference between cloning and copying a git repo?

查看:17
本文介绍了克隆和复制 git repo 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

同样的问题存在于 mercurial,我是想知道这如何适用于 git?特别是,我对有两个本地存储库以及使用 rsync 等在服务器之间进行复制的情况感兴趣.

The same question exists for mercurial, and I'm wondering how this applies to git? In particular, I'm interested in cases where there are two local repos, and copying between servers using rsync or such.

另外,如果原始 repo 本身是从 gitorious 克隆的,然后我复制了它,那么 gitorious 仍将作为远程(由 master 分支跟踪)存在于副本中,对吗?如果副本被克隆,会发生这种情况吗?

Also, if the original repo is itself cloned from, say gitorious, and I copy it, then gitorious will still exist as a remote (tracked by the master branch) in the copy, right? Does this happen if the copy is cloned instead?

推荐答案

克隆存储库会为您提供该存储库的副本并且将原始存储库配置为远程存储库.

Cloning a repository gives you a copy of that repository and configures the original repository as a remote.

复制存储库只会为您提供该存储库的副本.(虽然你当然可以在之后通过 git remote add 添加远程定义.)

Copying a repository just gives you a copy of that repository. (Though you can of course just add the remote definition afterwards via git remote add.)

复制存储库会复制其 .git/config 文件,从而复制其远程.克隆存储库不会复制配置文件,因此不会共享远程.(克隆的存储库在生成的克隆中设置为 origin 远程.)

Copying a repository copies its .git/config file, and thus its remotes. Cloning a repository does not copy the config file, and thus the remotes are not shared. (The repository that was cloned from is set as the origin remote in the resulting clone.)

这篇关于克隆和复制 git repo 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆