#####牛X哄哄参考资料:
ProGit
廖雪峰博客


###初始

  • 本地初始: 命令:
    git init```
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    * clone 命令:```$: git clone git://www.abc.com/abc.git```
    ###状态
    文件有两种状态:
    **unStaged(未跟踪) | staged(已跟踪)**
    *备注:只有已跟踪的文件才能提交到暂存区,之后才能提交到git仓库中*
    ###存储区域
    ** WorkArea(工作区)| Staged Area(暂存区) | Git Repository(Git仓库) **
    ###文件流程
    案例1: 新增文件> 加入暂存> 存入Git仓库
    操作 | 状态 | 存储区域
    --------------------- | ---- | ------
    新增readme | 未跟踪 | 工作区
    $:git add readme | 跟踪 | 暂存区
    $:git commit -m "add" | 跟踪 | Git仓库
    案例2: 新增文件,立即删除,不能恢复,因为文件处于未跟踪状态
    案例3: 删除文件(已经add)> 从暂存区恢复删除文件,文件将回到暂存区
    操作 | 状态 | 存储区域
    --------------------- | ---- | ------
    readme | 跟踪 | 暂存区
    $:rm readme | 跟踪 | 回收站
    $:git checkout readme | 跟踪 | 暂存区
    案例4: 删除文件(已经commit)> 从Git仓库中恢复
    操作 | 状态 | 存储区域
    --------------------- | ---- | ------
    readme | 跟踪 | Git仓库
    $:rm readme | 跟踪 | 回收站
    $:git checkout -- readme | 跟踪 | 暂存区
    案例5:文件已经commit没有添加相关Ignore导致每次提交都会产生.xcuserstate文件的提交信息,解决方案

$:git rm –cached path/Proj.xcuserstate
$:git commit -m “remove .xcuserstate”

```
添加 .gitignore文件, 参考文件https://github.com/github/gitignore


未完待续