本文操作环境:windows7系统、git2.30.0版、dell g3电脑。
git中clone是什么意思
git clone命令是在当前路径下创建一个新的目录,并复制git库到新创建的目录。
执行git clone命令的具体过程如下:
1.为git库中的每个branch,在本地目录中创建一个远程跟踪branch;
2.为git库中的active branch,在本地目录中创建并检出初始的branch;
3.为每个远程跟踪branch,执行git fetch;
4.为本地检查并初始的branch,执行git pull合并到本地目录中的初始branch中。
git clone 拷贝一个 git 仓库到本地,让自己能够查看该项目,或者进行修改。
拷贝项目命令格式如下:
git clone [url]
示例如下:
git clone [--template=<template_directory>] [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror] [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>] [--dissociate] [--separate-git-dir <git dir>] [--depth <depth>] [--[no-]single-branch] [--recursive | --recurse-submodules] [--[no-]shallow-submodules] [--jobs <n>] [--] <repository> [<directory>]
其中,常用的参数如下:
-n, 不检出git库中的active branch
-o new_origin, 使用new_origin,而不使用默认的origin,作为跟踪分支的upstream所在库
-b new_branch, 设置本地的active branch,而非默认的master branch
--single-branch, 只检查一个branch,要么是默认的master,要么是-b new_branch指定的new_branch
--recursive, 在本地初始化git库中的所有模块
推荐学习:《git教程》
以上就是git中clone是什么意思的详细内容。
