什么时候使用git rm -f?

Moh*_*ish 17 git git-rm

我正在学习Git,并且在发出"git rm"命令时无法理解在什么条件下使用-f标志.请解释一个场景,其中只需要rm -f而不是rm?

And*_*ndy 15

说明:

-f用于删除一个文件,如果该文件是不是最新的你最后检出提交.这是为了防止您删除已更改但尚未检入的文件.


例:

你看看包含文件sample.txt的提交0a12d4.你改变任何文件之前,你可以删除sample.txt的使用.但是,一旦对sample.txt进行了更改,就需要使用删除文件git rm sample.txtgit rm -f sample.txt