git远程添加和git克隆之间的区别

发布于 2024-10-15 04:26:46 字数 239 浏览 8 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

§普罗旺斯的薰衣草 2024-10-22 04:26:46

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.

帅的被狗咬 2024-10-22 04:26:46

它们在功能上相似(尝试一下!):

 # git clone REMOTEURL foo

并且:

 # mkdir foo
 # cd foo
 # git init
 # git remote add origin REMOTEURL
 # git pull origin main
 # cd ..

现在存在细微差别,但从根本上您可能不会注意到它们。作为留给读者的练习,比较每个目录中的 .git/config。

These are functionally similar (try it!):

 # git clone REMOTEURL foo

and:

 # mkdir foo
 # cd foo
 # git init
 # git remote add origin REMOTEURL
 # git pull origin main
 # cd ..

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.

看透却不说透 2024-10-22 04:26:46

git clone

将文件物理下载到您的计算机中。它将占用您计算机的空间。如果存储库有 200Mb,那么它将下载所有内容并将其放置在您克隆的目录中。

git remote add

不会占用空间!它更像是一个指针!它不会增加您的磁盘消耗。我相信它只是获取可用分支及其 git 提交历史记录的快照。它不包含项目的实际文件/文件夹。

如果您这样做:

git remote add TechLeadRepo  git://github.com/user/test.git

那么您还没有向计算机添加任何内容。将其添加到远程分支后,您可以通过执行以下操作来获取该远程上所有分支的列表:

git fetch --all

在获取(或拉取)时,您下载文件然后,如果您想获取同事的功能22 如果您克隆了他的存储

git checkout -b myLocalFeature22 TechLeadRepo/feature22

库,那么您将必须进入该本地存储库的目录,然后简单地 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:

git remote add TechLeadRepo  git://github.com/user/test.git

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:

git fetch --all

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

git checkout -b myLocalFeature22 TechLeadRepo/feature22

Had you cloned his repo then you would have to go into that local repository's directory and simply just checkout to your desired branch

稚然 2024-10-22 04:26:46

clone 命令创建您指定的存储库的本地副本。 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 is checkout.

心病无药医 2024-10-22 04:26:46

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文