git远程添加和git克隆之间的区别
clone
命令有什么作用? svn中有类似的东西吗?
有什么区别
git remote add test git://github.com/user/test.git
和
git clone git://github.com/user/test.git
?创建的存储库的名称很重要吗?
What does the clone
command do? Is there any equivalent to it in svn?
What is the difference between
git remote add test git://github.com/user/test.git
And
git clone git://github.com/user/test.git
Does the name of the created repo matter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
git remote add
只是在 git 配置中创建一个条目,指定特定 URL 的名称。您必须有一个现有的 git 存储库才能使用它。git clone
通过复制位于您指定的 URI 处的现有 git 存储库来创建一个新的 git 存储库。git remote add
just creates an entry in your git config that specifies a name for a particular URL. You must have an existing git repo to use this.git clone
creates a new git repository by copying an existing one located at the URI you specify.它们在功能上相似(尝试一下!):
并且:
现在存在细微差别,但从根本上您可能不会注意到它们。作为留给读者的练习,比较每个目录中的 .git/config。
These are functionally similar (try it!):
and:
Now there are minor differences, but fundamentally you probably won't notice them. As an exercise left to the reader, compare the .git/config's from each directory.
git clone
:将文件物理下载到您的计算机中。它将占用您计算机的空间。如果存储库有 200Mb,那么它将下载所有内容并将其放置在您克隆的目录中。
git remote add
:不会占用空间!它更像是一个指针!它不会增加您的磁盘消耗。我相信它只是获取可用分支及其 git 提交历史记录的快照。它不包含项目的实际文件/文件夹。
如果您这样做:
那么您还没有向计算机添加任何内容。将其添加到远程分支后,您可以通过执行以下操作来获取该远程上所有分支的列表:
在获取(或拉取)时,您下载文件然后,如果您想获取同事的功能22 如果您克隆了他的存储
库,那么您将必须进入该本地存储库的目录,然后简单地
checkout
到您想要的分支git clone
:Will physically download the files into your computer. It will take space from your computer. If the repo is 200Mb, then it will download that all and place it in the directory you cloned.
git remote add
:Won't take space! It's more like a pointer! It doesn't increase your disk consumption. It just gets a snapshot of what branches are available and their git commit history I believe. It doesn't contain the actual file/folders of your project.
If you do:
then you haven't added anything to your computer. After you've added it in your remote branches then you're able to get a list of all branches on that remote by doing:
upon fetching (or pulling), you download the files And then if you wanted to do get your colleague's feature22 branch into your local, you'd just do
Had you cloned his repo then you would have to go into that local repository's directory and simply just
checkout
to your desired branchclone
命令创建您指定的存储库的本地副本。remote add
添加一个可以推送或拉取的远程存储库。clone
的 svn 等效项是checkout
。The
clone
command creates a local copy of the repo you specified.remote add
adds a remote repo that you can either push to or pull from.The svn equivalent of
clone
ischeckout
.git clone URL
-将文件实际下载到您的计算机中。会占用空间
从您的计算机。如果存储库有 200 MB,那么它将下载所有内容
并将其放在您克隆的目录中。
git Remote add origin
-不会占用空间!它更像是一个指针!它不会增加您的磁盘空间
消耗。它只是获取可用分支及其分支的快照
我相信 git 提交历史。它不包含实际的文件/文件夹
您的项目。
git clone URL
-Will physically download the files into your computer. It will take space
from your computer. If the repo is 200 MB, then it will download that all
and place it in the directory you cloned.
git remote add origin
-Won't take space! It's more like a pointer! It doesn't increase your disk
consumption. It just gets a snapshot of what branches are available and their
git commit history I believe. It doesn't contain the actual files/folders
of your project.