3

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?

2 Answers 2

4

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.

0
1
git rm -- "path/to/\001\006@@x\021@8"

The following SO post is useful to understand double hyphen (--) option.

Deleting a badly named git branch

1
  • Informative, well explained, and completely misses the point ;-) The git rm -- somepath would help in the case when the filename starts with a -. The OP's problem is different.
    – janos
    Commented Dec 31, 2013 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.