git init
$ git init创建一个本地仓库
git add
添加所有改动到版本
$ git add .添加所有文件到版本
$ git add --all添加指定文件到版本
$ git add file.txtgit commit
提交改动
$ git commit -m'提交注释'git status
$ git status查看仓库状态
git branch [branch]
查看本地分支
$ git branch创建本地分支gh-pages
$ git branch gh-pagesgit checkout [branch]
选择分支gh-pages
$ git checkout gh-pagesgit push -u [remote] [branch]
推送本地分支到远端
$ git push -u origin gh-pagesgit pull [remote] [branch]
拉取最新版本代码到本地
$ git pull origin gh-pagesgit checkout -b [local_branch] [origin_branch]
检出远程分支并选择改分支
$ git checkout -b gp-pages mastergit fetch origin [branch]
检出远程分支但不会选择到改分支
$ git fetch origin mastergit merge [branch]
将其他分支合并到本分支
$ git merge gh-pagesgit branch -a
查看所有分支(远程和本地)
$ git branch -agit diff
比较某个分支与当前分支的区别
$ git diff branch比较制定两个分支的区别
$ git diff branch1..branch2or
$ git diff branch1 branch2git difftool [branch1] [branch2]
首先安装git外部比较工具(这里是mac版)
安装方法如:www.cnblogs.com/ayseeing/p/…
按照步骤下载安装后执行如下如下命令
比较两个分支差异
$ git difftool gh-page masteror
比较当前分支差异文件
$ git difftool gh-page