删除文件
在 git 中删除也是一个修改操作
假如你rm 或 永久删除了一个文件
再使用git status,git 会告诉你哪些文件被删除了
git status
# On branch master
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git restore <file>..." to discard changes in working directory)
# deleted: readme.md
#
# no changes added to commit (use "git add" and/or "git commit -a")
现在你有两个选择:
- 是确实要从版本库中删除该文件,那就用命令
git add/rm删除,并且git commit - 使用
git restore <file>把误删的文件恢复到暂存区的状态