linux clone命令,git clone命令
发布日期:2021-06-24 13:44:25 浏览次数:2 分类:技术文章

本文共 1650 字,大约阅读时间需要 5 分钟。

git clone命令将存储库克隆到新目录中。

简介

git clone [--template=]

[-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]

[-o ] [-b ] [-u ] [--reference ]

[--dissociate] [--separate-git-dir ]

[--depth ] [--[no-]single-branch]

[--recurse-submodules] [--[no-]shallow-submodules]

[--jobs ] [--] []

描述

将存储库克隆到新创建的目录中,为克隆的存储库中的每个分支创建远程跟踪分支(使用git branch -r可见),并从克隆检出的存储库作为当前活动分支的初始分支。

在克隆之后,没有参数的普通git提取将更新所有远程跟踪分支,并且没有参数的git pull将另外将远程主分支合并到当前主分支(如果有的话)。

此默认配置通过在refs/remotes/origin下创建对远程分支头的引用,并通过初始化remote.origin.url和remote.origin.fetch配置变量来实现。

执行远程操作的第一步,通常是从远程主机克隆一个版本库,这时就要用到git clone命令。

$ git clone

比如,克隆jQuery的版本库。

$ git clone http://github.com/jquery/jquery.git

该命令会在本地主机生成一个目录,与远程主机的版本库同名。如果要指定不同的目录名,可以将目录名作为git clone命令的第二个参数。

$ git clone

git clone支持多种协议,除了HTTP(s)以外,还支持SSH、Git、本地文件协议等,下面是一些例子。

示例

以下是所支持协议的一些示例 -

$ git clone http[s]://example.com/path/to/repo.git

$ git clone http://git.oschina.net/yiibai/sample.git

$ git clone ssh://example.com/path/to/repo.git

$ git clone git://example.com/path/to/repo.git

$ git clone /opt/git/project.git

$ git clone file:///opt/git/project.git

$ git clone ftp[s]://example.com/path/to/repo.git

$ git clone rsync://example.com/path/to/repo.git

SSH协议还有另一种写法。

$ git clone [user@]example.com:path/to/repo.git

通常来说,Git协议下载速度最快,SSH协议用于需要用户认证的场合。

应用场景示例

从上游克隆下来:

$ git clone git://git.kernel.org/pub/scm/.../linux.git mydir

$ cd mydir

$ make # 执行代码或其它命令

在当前目录中使用克隆,而无需检出:

$ git clone -l -s -n . ../copy

$ cd ../copy

$ git show-branch

从现有本地目录借用从上游克隆:

$ git clone --reference /git/linux.git

git://git.kernel.org/pub/scm/.../linux.git

mydir

$ cd mydir

创建一个裸存储库以将您的更改发布给公众:

$ git clone --bare -l /home/proj/.git /pub/scm/proj.git

转载地址:https://blog.csdn.net/weixin_33239721/article/details/116838216 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:linux拷贝账户到mnt,linux基础与应用 -电脑资料
下一篇:linux 管理桌面图标,使用GNOME优化工具自定义Linux桌面的10种方法

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月09日 12时44分24秒