[git 学习篇]删除文件

1 现在本地文件管理器删除了readme.txt(这个readme.txt已经在创库存在的)

  rm -rf readme.txt

2 此时git status查看

  

$ 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")

3 此时有两个选择: 

(1)确实是想删除创库的readme.txt ,那么执行: git rm readme.txt ; git commit -m "remove readme.txt"

(2)如果是误删,那么执行 git checkout -- readme.txt 

4 如果文件已经在创库上,而且你有误删,而且git commit了,怎么办? 

只能回到上一个版本

posted @ 2017-06-23 10:35  liuzhipenglove  阅读(288)  评论(0编辑  收藏  举报