@ghimi
2018-08-16T10:05:27.000000Z
字数 359
阅读 1191
未分类
使用 git rm
命令即可,有两种选择:
* 使用git rm --cached /file/to/remove
,不删除物理文件,仅将该文件从缓存中删除.
* 使用git rm --f /file/to/remove
,不仅将该文件从缓存汇总删除,还会降物理文件删除(不会回收到垃圾桶)
git rm --cache
和 git reset HEAD
的区别在哪里呢?如果要删除文件,最好使用 git rm /file/to/remove
,而不应该直接在工作区 rm /file/to/remove
如果一个文件已经 add 到暂存区,还没有 commit ,此时如果不想要这个文件了,有两种办法:
1. 用版本库内容清空暂存区, git reset HEAD
但要谨慎使用
2. 只把特定文件从暂存区删除,git rm --cached /file/to/remove