I have done the following (in order to learn git rm).

Created an empty repository on an empty folder. Created a file called test.txt, modify it and then run the following (with the consequent results).

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)

So, my question is:

When would git rm test.txt be actually useful?

有帮助吗?

解决方案

When would git rm test.txt be actually useful?

When you have already added and committed the file to your repository. The docs tell us that git rm is used to:

Remove files from the index, or from the working tree and the index.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top