Reputation: 55
I'm not sure how, but a co-worker created a file with an invalid name (slash in file name, "MCHS \226 FH La Crosse.xlsx"). This file has been deleted now, but I can't seem to get git to forget about it. I'm still able to pull/push/commit but I've been staring at this message every time I sync my repos for the past year now, and today I decided I've had enough and I need it gone.
I tried to do a git rm but I got the error "did not match any files". I can't physically recreate a file with that filename, to complete the rm, because of the slash in the name...any suggestions?
Upvotes: 1
Views: 1431
Reputation: 369
git rm -r --cached -- "path/to/directory"
git pull
git rm "path/to/directory"
git add "path/to/directory"
git push
git pull
Upvotes: 2
Reputation: 3139
git rm
is to remove existing files from your index and/or working tree. It won't do anything for a file that has already been deleted. Instead, you probably have to commit the file deletion.
In the terminal, $ git status
in your project. You should see something like
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: MCHS \226 FH La Crosse.xlsx
Add the file and commit it:
git add "MCHS \\226 FH La Crosse.xlsx"
git commit -m "remove deleted file from remote repo"
Finally, push to your remote repo.
Upvotes: 1