git中clone是“克隆”、“復(fù)制”的意思,clone命令可以在當(dāng)前路徑下創(chuàng)建一個新的目錄,并復(fù)制git庫到新創(chuàng)建的目錄,就能夠查看或者修改該項目,語法為“git clone [url]”。
本文操作環(huán)境:Windows7系統(tǒng)、Git2.30.0版、Dell G3電腦。
git中clone是什么意思
git clone命令是在當(dāng)前路徑下創(chuàng)建一個新的目錄,并復(fù)制Git庫到新創(chuàng)建的目錄。
執(zhí)行g(shù)it clone命令的具體過程如下:
1.為Git庫中的每個branch,在本地目錄中創(chuàng)建一個遠(yuǎn)程跟蹤branch;
2.為Git庫中的active branch,在本地目錄中創(chuàng)建并檢出初始的branch;
3.為每個遠(yuǎn)程跟蹤branch,執(zhí)行g(shù)it fetch;
4.為本地檢查并初始的branch,執(zhí)行g(shù)it pull合并到本地目錄中的初始branch中。
git clone?拷貝一個 Git 倉庫到本地,讓自己能夠查看該項目,或者進(jìn)行修改。
拷貝項目命令格式如下:
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>] ????[--depth?<depth>]?[--[no-]single-branch] ????[--recursive?|?--recurse-submodules]?[--[no-]shallow-submodules] ????[--jobs?<n>]?[--]?<repository>?[<directory>]</directory></repository></n></depth></git></repository></upload-pack></name></name></template_directory>
其中,常用的參數(shù)如下:
-n, 不檢出Git庫中的active branch
-o new_origin, 使用new_origin,而不使用默認(rèn)的origin,作為跟蹤分支的upstream所在庫
-b new_branch, 設(shè)置本地的active branch,而非默認(rèn)的master branch
–single-branch, 只檢查一個branch,要么是默認(rèn)的master,要么是-b new_branch指定的new_branch
–recursive, 在本地初始化Git庫中的所有模塊