假如我们在文件系统中把一个文件test.txt删掉,执行git stauts可以看到
$ git status
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: test.txt
no changes added to commit (use "git add" and/or "git commit -a")
可见,现在你有两个选择,一是确实要从版本库中删除该文件,那就用命令git rm
删掉,并且git commit,如:
git rm test.txt
git commit -m '删除test.txt文件'
另一种情况是删错了,因为版本库里还有呢,所以可以很轻松地把误删的文件恢复到最新版本:
git checkout -- test.txt