A file has accidentally been added to your staging area, find out which file and remove it from the staging area. *NOTE* Do not remove the file from the file system, only from git.
有一個(gè)文件不小心被添加到了暫存區(qū),找到它,然后把它從暫存區(qū)中刪除。*注意* 不是要把它從文件系統(tǒng)里刪除,只是要從 Git 暫存區(qū)刪除。
有時(shí)候,我們用 git add
命令添加到暫存區(qū)的文件中無(wú)意中包含了不應(yīng)該添加的文件,這時(shí)如果要撤銷添加,就要做 git add
的逆操作。能進(jìn)能退,Git 方為真正法器。
撤銷添加到暫存區(qū)的命令仍是 git rm
,但要加一個(gè) --cached
參數(shù),如下面所示:
$ git rm --cached your-file
第12關(guān)過(guò)關(guān)畫面如下:
http://wiki.jikexueyuan.com/project/githug-walkthrough/images/level-12-rm-cached.png" alt="第12關(guān) rm_cached" />