0

我做了以下(为了学习git rm)。

在空文件夹上创建了一个空存储库。创建了一个名为 test.txt 的文件,对其进行修改,然后运行以下命令(以及随之而来的结果)。

git rm test.txt -> `fatal: pathspec 'test.txt' did not match any files`

git add test.txt && git rm test.txt -> 
error: 'test.txt' has changes staged in the index
                   (use --cached to keep the file, or -f to force removal)

所以,我的问题是:

test.txt 什么时候git rm真正有用?

4

1 回答 1

1

什么时候git rm test.txt真正有用?

当您已经将文件添加提交到您的存储库时。文档告诉我们git rm它用于:

从索引中删除文件,或者从工作树和索引中删除文件。

于 2014-02-12T04:23:37.707 回答