I have recently acquired a couple corrupted files in my github repository. I have deleted them from my host but I'm having trouble removing them with git because they have messed up names. They show up like this under git status
# 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: "\001\006@@x\021@8"
# deleted: "path/to/\001\006@@x\021@8"
#
I've tried
git rm "path/to/\001\006@@x\021@8"
But I get the error
fatal: pathspec 'path/to/\001\006@@x\021@8' did not match any files
Any idea how I can properly remove these files from the repo?
It's not Git that has problem removing that file, the problem is telling it to Git the right way in the shell. Due to the special symbols this is tricky, but you can do it like this:
git rm $(echo -e "path/to/\001\006@@x\021@8")
Btw, in your specific case, and based on the output of your git status
, you could actually skip the git rm
and simply git commit -a
. The -a
or --all
flags makes git
commit all pending changes, including unstaged changes and deleted files.