更新时间:2023-12-04 20:44:28
你想要:
You want:
git rm --cached [file]
如果省略 --cached
选项,它也会从工作树中删除它。 git rm
比 git reset
安全得多,因为如果暂存的内容不符合分支的尖端或磁盘上的文件。 (如果没有,你必须添加 - force
。)
If you omit the --cached
option, it will also delete it from the working tree. git rm
is slightly safer than git reset
, because you'll be warned if the staged content doesn't match either the tip of the branch or the file on disk. (If it doesn't, you have to add --force
.)