[TOC]
## 1.三個區的概念(工作區,暫存區,版本庫)
~~~
git init
git config --global user.name chengbenchao
git config --global user.email 395775347@qq.com
git config --global --list
git config --get user.name
git add xx
~~~
> //添加所有修改的內容
~~~
git add .
git commit -m"xxx"
git status
git diff
~~~
## 2.版本回退
~~~
git log
git log --pretty=oneline
git reflog
git reset --hard XXXXX
~~~
## 3.撤銷修改和刪除
~~~
git checkout xx
git rm xx
~~~
> //從版本庫中刪除后,要commit
`git commit -m"xx"`
## 4.本地倉庫和遠程倉庫的連接
~~~
git remote add origin xxx
git push -u origin master
git remote -v
~~~
> //取消遠程關聯倉庫
`git remote remove origin`
## 5.克隆遠程倉庫到本地
`git clone xxx`
## 6.配置ssh
`ssh-keygen -t rsa -C 395775347@qq.com`
## 7.分支管理
~~~
//查看分支
git branch
//創建分支
git branch <name>
//切換分支
git checkout <name>
//創建+切換分支
git checkout -b <name>
//和遠程分支連接
git checkout -b <branch name> origin/<branch name>
//合并某分支到當前分支
git merge <name>
git merge --no-ff -m"xx" <branch name>
//查看分支合并圖
git log --graph --pretty=oneline --abbrev-commit
//將修改內容添加到工作區的存儲區
git stash
//查看存儲區的內容
git stash list
//恢復存儲區的內容
git stash pop
//刪除分支
git branch -d <branch name>
git branch -D <branch name>
~~~
## 8.推送分支
`git push origin <branch name>`