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這些操作。

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