I am trying to remove a file from the git repository. However, when I do:
git rm <file name>
fatal: pathspec 'file1.txt' did not match any files
The two files still untracked files!
I am trying to remove a file from the git repository. However, when I do:
git rm <file name>
fatal: pathspec 'file1.txt' did not match any files
The two files still untracked files!
Here, git rm
is telling you that the file you are telling it to remove is already not going to be in the next commit you make:
$ git rm new.html fatal: pathspec 'new.html' did not match any files
You added this last line:
The two files still untracked files!
I don't quite know what you mean to say here (among other things, this sentence has no verb), but the fact is that an untracked file is a file that won't be in the next commit you make. It's therefore impossible for Git to remove it from the proposed next commit: it's not in the proposed next commit.
The git rm
command will remove a file from two places: the proposed next commit, and your working tree. For this to happen, the file has to be in both places.
Files that you can see—that show up in ls
output—are not actually the files that are in the repository. When you run git checkout
, Git will copy files that are in the repository into your working tree, but other files that already exist in your working tree—that you put there yourself, for instance—just sit there, unmodified. They're not in the proposed next commit, because the initial proposed next commit consists of the files copied out of the current commit.
When git status
reports files as untracked, that means they are not in your proposed next commit, so that if you commit now, they will not be in that commit.