ILD

git clone
作者:Herbert Yuan 邮箱:yuanjp@hust.edu.cn
发布时间:2018-5-13 站点:Inside Linux Development

git clone 将一个仓库克隆到新的目录。


语法(只包含常用选项):

1
git clone [-n] [-o <name>] [-b <name>] <repository> [<directory>]


描述:

克隆一个仓库到新创建的文件夹,为本地克隆仓库创建每个branch的remote-tracking branches,可以使用git branch -r查看。创建并check out一个初始分支,该分支是被克隆仓库的当前活动分支。

克隆之后,git fetch不带参数的话,将更新所有的remote-tracking branches,git pull不带参数的话,还会额外将远端master分支合并到当前master分支。


选项:

-no-checkout

-n

克隆后不要checkout HEAD


--origin <name>

-o <name>

使用指定的<name>作为远程名,默认为remote。


--branch <name>

-b <name>

使用指定的分支,作为当前分支,而不是仓库的当前活动分支。


Shallow clone 浅拷贝

--depth <depth>

只拷贝最新的depth个commit。默认开启--single branch选项,除非指定了--no-single-branch。


--shallow-since=<data>

创建指定日期后的浅拷贝。


--[no-]single-branch

只拷贝单个branch


--[no-]shallow-submodules

所有的子模块按depth=1拷贝。



参考:

https://git-scm.com/docs/git-clone

https://www.perforce.com/blog/git-beyond-basics-using-shallow-clones



Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.