Git Windows 平台上安装 安装配置

2998

在 Windows 平台上安装 Git 同样轻松,有个叫做 msysGit 的项目提供了安装包,可以到 GitHub 的页面上下载 exe 安装文件并运行:

安装包下载地址:http://msysgit.github.io/

1457876806168896.jpg

完成安装之后,就可以使用命令行的 git 工具(已经自带了 ssh 客户端)了,另外还有一个图形界面的 Git 项目管理工具。

在开始菜单里找到"Git"->"Git Bash",会弹出 Git 命令窗口,你可以在改窗口进行 Git 操作。


克隆一个项目来试试:。例如thinkphp5.0 Git 方式:

下面是thinkphp5.0 Git地址

blob.png


"Git Bash" 中命令:

$ git clone <版本库的网址>

比如,应用项目:https://github.com/top-think/think

$ git clone https://github.com/top-think/think tp5

上面这条命令就可以将项目克隆下来了,但是默认的目录是在C:\Users\Administrator\tp5


该命令会在本地主机生成一个目录,与远程主机的版本库同名。如果要指定不同的目录名,可以将目录名作为git clone命令的第二个参数。

$ git clone <版本库的网址> <本地目录名>

如果要将克隆下面项目放在我们要放在本地目录只要下面的命令就可以:

例如:克隆项目的目录在 F盘gittp5目录中!!!

$ git clone https://github.com/top-think/think f:/gittp5.git

git clone支持多种协议,除了HTTP(s)以外,还支持SSH、Git、本地文件协议等,下面是一些例子。

$ 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/