Git——概念——工作区

  工作区,英文workspace,它存储着开发者的文件和文件夹,以及.git版本库。若是裸版本库,是只有.git版本库,没有工作区的。

  工作区的文件分为三种类型

Tracked:A tracked file is any file already in the repository or any file that is staged in the index, to add a new file somefile to this group, run git add somefile

已追踪的文件。

Ignored:An Ignored file must be explicitly declared invisible or ignored in the repository even though it may be present within your working directory

被忽略的文件。

Untracked:An untracked file is any file not found in either of the previous two categories

未追踪的,不属于上述两类的都是未追踪文件,例如新创建的Hello.txt,还未stage(过渡)到Index(索引)中。

工作区与版本库之间,本质是将工作区的文件入库,版本库根据已入库文件,还原(restore)工作区

1、入库

 被忽略文件:不会入库。

  已追踪文件:文件夹或文件名转换为tree对象,文件内容转换为blob对象。

  未追踪文件:等待入库,执行git add或git commit之后,变为已追踪文件,入库。

  版本库存储文件时,是将内容和路径分开存储的,所以当a.txt和b.txt文件写入的内容都是”Hello World”时,只会有一个blob对象。

  已追踪文件是无法转换为被忽略文件和未追踪文件的。例如hello.txt已经提交之后,在.gitignore上添加hello.txt时,它的修改还会被记录。

2、还原

  根据.git目录可以还原出某个commit对象对应的工作区。例如git checkout, git reset这些操作。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章