且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从git中的索引中删除文件?

更新时间: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.)