下载及安装
参考廖雪峰Git教程http://dwz.cn/7b5LgF
- 打开Github官方网址下载
https://git-scm.com/download/win
; - 安装完成后,右击鼠标打开Git Bash命令符,设置登陆github的用户名和邮箱地址 ;
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
git版本控制器的原理
- 将本地文件传入本地git仓库中
- 从本地git仓库上传文件到github等远程服务器上
原理:本地文件 —>本地git仓库—>Github等远程服务器
创建repository(仓库)
- 新建
new repository
- 打开Git Bash命令符
echo "# HTML5" >> README.md //echo是print的意思,‘>’是管道符,表示以此内容覆盖原文件内容,‘>>’表示添加内容进文件,类似appened(echo和管道符都是linux的操作命令)
git init //git初始化,后台建立`.git`文件夹
git add README.md // 将本地文件传入本地git中
git commit -m "first commit" // 将本地文件保存本地git中,‘-m’(comment)表示添加注释,字符串是注释内容
git remote add origin https://github.com/raoxiaojing/HTML5.git // 建立本地git与远程服务器指定仓库的链接
git push -u origin master // 将本地git文件推入仓库中,第一次执行时必须加上‘-u’,之后的操作则不需要。
Pull github项目
- 复制项目repository地址 ;
- 在Bash命令符里创建新的文件夹
$ mkdir -p react_demo
,(一个文件夹只能链接一个仓库); - 进入新创建的文件夹
cd react_demo/
- pull github repository地址
$ git pull http://github.com/zzjack/react_demo