远程操做的第一步,一般是从远程主机克隆一个版本库,这时就要用到git clone命令。jquery
$ git clone <版本库的网址>
好比,克隆jQuery的版本库。git
$ git clone https://github.com/jquery/jquery.git
该命令会在本地主机生成一个目录,与远程主机的版本库同名。若是要指定不一样的目录名,能够将目录名做为git clone命令的第二个参数。github
$ git clone <版本库的网址> <本地目录名>
git clone支持多种协议,除了HTTP(s)之外,还支持SSH、Git、本地文件协议等,下面是一些例子。ssh
$ git clone http[s]://example.com/path/to/repo.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/
SSH协议还有另外一种写法。文档
$ git clone [user@]example.com:path/to/repo.git/
一般来讲,Git协议下载速度最快,SSH协议用于须要用户认证的场合。各类协议优劣的详细讨论请参考官方文档。it