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这个区域。你一般不会丢失任何信息,但是你必须得知道文件树结构的名称。