企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 语法 ``` -b, --branch <branch> clone时指定分支 --depth <depth> 创建该深度的浅层克隆 --single-branch 只克隆一个分支,HEAD或- branch --separate-git-dir <gitdir> separate git dir from working tree -c, --config <key=value> set config inside the new repository --filter 部分克隆 --progress 展示clone 的百分比 ``` ### 支持的协议 ``` $ 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 <branch_name> http://example.com:path/to/repo.git repo1 ``` ### 按深度 clone ``` git clone --depth=1 <url> ``` ### 按需下载 --filter=blob:none 这种按需下载大大减少了传输的数据量和过程的耗时,同时还可以降低本地磁盘空间的占用。在后续工作中需要用到这些缺失文件的时候,Git会自动的**按需下载**这些文件,在不必进行任何额外的配置的情况下,用户仍然可以正常的开展工作 ``` git clone --mirror git@codeup.aliyun.com:6125fa3a03f23adfbed12b8f/linux.git linux ``` ### --progress 进度 ``` > git clone https://github.com/example/repo.git --progress Cloning into 'repo'... remote: Enumerating objects: 500, done. remote: Counting objects: 100% (500/500), done. remote: Compressing objects: 25% (125/500) Receiving objects: 100% (500/500), 3.21 MiB | 1.20 MiB/s, done. Resolving deltas: 100% (250/250), done. ```