Getting Started
which git 查看是否安装gitgit help 查看帮助git help <关键字> 查看具体命令ls -a 查看所有文件, 包括隐藏文件touch <file> 新建文件git add -A     -A, —all: add changes from all tracked and untracked filesgit add . 添加当前目录所有文件
SHA 发音 /shah/ Secure Hash Algorithmecho "hello, world" > index.html 写入信息到文件 > 覆盖, >> appenddiff <file> <file> 查看文件差异git diff shows the difference between the last commit and unstaged changesgit diff <file> 查看某个文件的更改git commit -a -m "xxx" -a 只包括已经tracked的文件git commit -am "xxx" 和git commit -a -m一样git commit --amend 修改当前commitgit show <SHA> 查看某个commit的详细提交信息start <file> windows上打开文件, unix用 opengit log -p 显示出详细的diff
Backing Up and Sharing
It’s important to able to follow a series of commands even if you don’t completely understand them.
生成SSH
官方文档ls -al ~/.ssh 查看是否存在SSH key文件(id_rsa.pub)ssh-keygen -t rsa -b 4096 -C "your_email@example.com" 生成SSH keycat~/.ssh/id_rsa.pub 查看公钥, 添加到Githubssh -T git@github.com 测试是否添加成功rm-f ~/.ssh/id_rsa rm-f ~/.ssh/id_rsa.pub 删除key
Remote
git remote add origin https://github.com/<name>/website.git 添加远程仓库git push -u origin master -u 代表upstream, 可以理解为默认仓库git push 推送到默认仓库
Intermediate workflow
mkdir images 创建文件夹curl -o images/breaching_whale.jpg -OL cdn.learnenough.com/breaching_whale.jpg 下载图片
touch .gitignore 添加忽略文件echo .DS_Store >> .gitignore 将要排除的文件写入.gitignoreecho *.exe >> .gitignore 使用通配符echo tmp/ >> .gitignore 排除目录
*星号代表当前checked out的分支
cp index.html about.html 将index.html拷贝为about.htmlgit add -A && git commit -m "Add about page" 2个命令一起用
git diff <branch1> <branch2> 比较2个分支的不同, 如果省去第二个分支,则和当前分支对比git diff master
echo >> about.html 在文件末尾插入新的一行
**git checkout -f** 强制checkout到HEAD, 即撤销当前未提交的修改 -f代表forcegit reset --hard 同上
推荐在分支上修改,如果出错了,直接将分支删除就好了
Collaborating
在Github项目的Settings里可以添加合作者collaborator
git clone <clone URL> <directory-name> 克隆到本地自定义文件夹
git pull 产生冲突
修改冲突后, 直接**git commit -a** 或者 **git commit -am "xxx"**
A 上传分支 **git push -u origin fix-trademark**
B 下载分支
发现查看不到分支
因为这是远程分支, 应使用命令 git branch -r 查看远程分支, 或者 git branch -a 查看所有分支
只要做一次checkout就能变成本地分支了

删掉远程分支**git push origin --delete fix-trademark**
生成Github Pages, 只需要产生一个gh-pages分支**git checkout -b gh-pages****git push -u origin gh-pages**
 打开网址 http://
Conclusion
推荐教程:
Pro git
Git tutorials 
