从暂存区域git中删除“h origin ...”文件

问题描述 投票:0回答:2

我在我的暂存区域的某个地方有一个奇怪的文件,我不想提交。但我很难将其删除......

$ 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

我想删除“h origin \ 357 \ 200 \ 27295320_fix_text”

git
2个回答
0
投票
git rm h\ origin\ *_fix_text

要么

git rm "h origin "*_fix_text

0
投票

你正走在正确的轨道上:

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

git status用反斜杠在双引号中打印此名称的原因是该名称本身包含不可打印的字符。如果Git试图打印字符,它们就不一定能正常出现。 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.它可能会打印一个奇怪的块状角色(它在我的Mac上),或者什么都没有,或者谁知道什么。

不知何故,你必须将相同的字节序列输入到git rm --cached。由于您似乎使用了解POSIX编码的sh / bash-ish shell,因此您可以尝试:

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

它使用$'...'语法,它告诉shell以与Git生成它们相同的方式解释转义序列。 (您必须使用单引号,而不是双引号。)

(顺便说一句,粘贴Mac的输出:

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

在我的浏览器中显示为同样奇怪的块状字符--Mac最佳尝试显示该Unicode字符。我不确定它在其他操作系统上的其他浏览器上是如何显示的。)

© www.soinside.com 2019 - 2024. All rights reserved.