#### **1.創建版本庫**
①本地倉庫創建
```
git init 或 git init 指定目錄
```
~~~
# 創建用戶信息
git config --global user.name '用戶名'
git config --global user.email '郵箱號'
~~~
②遠程倉庫克隆
```
git clone git://github.com/schacon/grit.git <dir>
```
#### **2.基礎操作**
①檢查是否需要同步的文件
```
git status -s
```
②查看文件修改
```
git diff <file>
```
③將文件添加到本地緩存
```
git add 文件名
git add .(添加所有)
```
④提交到版本庫中
~~~
git commit -m '提交備注'
~~~
⑤整合添加緩存和提交版本庫
~~~
git commit -am '提交備注'
git push # 推送到遠程倉庫
~~~
⑥撤銷本地緩存
```
git reset HEAD 文件名
git reset --soft HEAD^ #撤銷最后一次
```
⑦丟棄工作區的修改
```
~~~
git checkout -- 文件名
~~~
```
#### **3.刪除文件**
①刪除本地文件
```
rm file
```
②刪除倉庫中的文件
~~~
git commit -m "remove file"
~~~