【Git】删除文件(转载)

转载于廖雪峰的git教程

在Git中,删除文件也是一个修改操作

先添加一个新的文件test.txt到Git并且提交

git add test.txt
git commit -m "add test.txt"

一般情况, 你通常在文件管理器中把没有用的文件删了,或者使用rm命令删了

rm test.txt

这个时候, git知道你删除了文件, 因此,工作区域和版本库就不一致了, git status命令会告诉你哪些文件被删除了

$ git status
On branch master
Changes not staged for commit:
  (use "git add/rm ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

	deleted:    test.txt

no changes added to commit (use "git add" and/or "git commit -a")

现在你有两个选择,

你可能感兴趣的:(操作系统知识,git,github)