Search code examples
gitgithubcmder

How can I make Git forget/remove a deleted file that has an invalid filename?


Screenshot

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?


Solution

  • git rm -r --cached -- "path/to/directory"
    
    git pull
    
    git rm "path/to/directory"
    
    git add "path/to/directory"
    
    git push
    
    git pull