git-clone

1.clone说明

git clone它的作用是将远程仓库的代码复制到本地仓库,方便对代码进行修改和管理。

2clone案列

2-1.全克隆

默认的分支是master/main

git clone仓库url。存在一个问题,当clone的仓库很大的时候,而github又是比较慢的clone速度,导致等待的时间较长。

# git clone时会在当前目录下创建一个同名的文件夹
git clone https://github.com/username/repo.git

# 等同上面
git clone https://github.com/username/repo.git repo

# clone时改名
git clone https://github.com/username/repo.git repo_test

2-1.克隆指定分支-b

git clone <url>git clone -b <branch> <url>二者结果一致,他们都是将git仓库分支以及信息全部下载到本地

git clone -b dev https://github.com/username/repo.git

2-3.克隆单一分支--single-branch

github工程文件很大情况,推荐使用git clone -b <branch> --single-branch <url>。缺点是看不到其他分支

git clone -b dev --single-branch https://github.com/username/repo.git

2-4.克隆深度--depth

下载的代码只会显示最近几条的log

git clone --depth=3 https://github.com/username/repo.git
posted @ 2023-07-15 14:55  lxd670  阅读(108)  评论(0编辑  收藏  举报