Git Index是工作目錄和倉庫的一個臨時區域,或者稱之為暫存區域。你可以用這個Index去建立你要一起提交的變更。當你做一個Commit,這個Commit的當前是在Index的,而不是在工作目錄中內容。
要查看什么是Index,最好的辦法是用Git Status這條命令。這條顯示可以顯示哪些文件被staged(在index里面),哪些修改還沒有被staged,哪些還沒有被跟蹤。
$>git status # On branch master # Your branch is behind 'origin/master' by 11 commits, and can be fast-forwarded. # # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: daemon.c # # Changed but not updated: # (use "git add <file>..." to update what will be committed) # # modified: grep.c # modified: grep.h # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # blametree # blametree-init # git-gui/git-citool
如果完全不要Index這個區域。你一般不會丟失任何信息,但是你必須得知道文件樹結構的名稱。