clone
最后更新于:2022-04-02 02:52:57
[TOC]
## 语法
```
-b, --branch clone时指定分支
--depth 创建该深度的浅层克隆
--single-branch 只克隆一个分支,HEAD或- branch
--separate-git-dir
separate git dir from working tree
-c, --config
set config inside the new repository
```
### 支持的协议
```
$ 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/
```
>Git协议下载速度最快
## 场景
### 指定目录
```
git clone http://example.com:path/to/repo.git repo1
```
### 在clone时候输入账号密码
```
git clone [http|git]://user:password@example.com:path/to/repo.git
```
### clone 时指定分支
```
git clone -b http://example.com:path/to/repo.git repo1
```
### 按深度 clone
```
git clone --depth=1
```
';