0

I have a weird file from someplace in my staging area that I do not want to commit. But I am having a hard time removing it...

$ git st
On branch 112929_shedd
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   RDI.Core/Business/Utilities/IntranetMaintData.cs
        new file:   "h origin \357\200\27295320_fix_text"
        modified:   privatedn/Employees/SkillsMatrix/Certifications.aspx
        modified:   privatedn/Employees/SkillsMatrix/Education.aspx
        modified:   privatedn/Employees/SkillsMatrix/Organizations.aspx
        modified:   privatedn/Employees/SkillsMatrix/ProjectHistory.aspx
        modified:   privatedn/Employees/SkillsMatrix/Publications.aspx
        modified:   privatedn/Employees/SkillsMatrix/References.aspx
        modified:   privatedn/Employees/SkillsMatrix/SkillsGroupDetails.aspx
        modified:   privatedn/Employees/SkillsMatrix/SkillsMatrixMaster.master
        modified:   privatedn/Employees/SkillsMatrix/TextFilter.aspx
        modified:   privatedn/MenuGroupDetails.aspx.cs

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   privatedn/RDI.Intranet.csproj

$ git rm --cached "h origin \357\200\27295320_fix_text"
fatal: pathspec 'h origin \357\200\27295320_fix_text' did not match any files

I want to remove "h origin \357\200\27295320_fix_text"

torek
  • 448,244
  • 59
  • 642
  • 775
fallingdog
  • 192
  • 1
  • 2
  • 17
  • also tried git reset HEAD "h origin \357\200\27295320_fix_text" – fallingdog Jan 04 '18 at 19:06
  • Please add the output of `ls`. The file should be there since it’s not listed in the “not staged“ section. – Melebius Jan 04 '18 at 19:58
  • Possible duplicate of [Unstage only new files using Git](https://stackoverflow.com/questions/24394630/unstage-only-new-files-using-git) – Melebius Jan 04 '18 at 20:01

2 Answers2

0
git rm h\ origin\ *_fix_text

or

git rm "h origin "*_fix_text
phd
  • 82,685
  • 13
  • 120
  • 165
0

You're on the right track with:

git rm --cached "h origin \357\200\27295320_fix_text"

but the reason git status printed this name in double quotes with backslashes is that the name itself contains unprintable characters. If Git attempted to print the characters, they wouldn't necessarily come out properly. The three byte sequence 0357, 0200, 0272 (decimal 239, 128, 186) is the UTF-8 encoding of the Unicode character U+F03A, which is in a reserved block. It might print a weird blocky character (it does on my Mac), or nothing at all, or who knows what.

Somehow, you must feed this same byte-sequence in to git rm --cached. Since you appear to using an sh/bash-ish shell that understands POSIX encoding, you can try:

git rm --cached $'h origin \357\200\27295320_fix_test'

which uses the $'...' syntax, which tells the shell to interpret the escape sequences the same way that Git generates them. (You must use single quotes, not double quotes.)

(Incidentally, pasting the Mac's output here:

$ echo $'h origin \357\200\27295320_fix_test' 
h origin 95320_fix_test

shows up in my browser as the same weird blocky character—the Mac's best attempt to display that Unicode character. I'm not sure how it shows on other browsers on other OSes.)

torek
  • 448,244
  • 59
  • 642
  • 775