我在我的暂存区域的某个地方有一个奇怪的文件,我不想提交。但我很难将其删除......
$ 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
我想删除&#34; h origin \ 357 \ 200 \ 27295320_fix_text&#34;
答案 0 :(得分:0)
git rm h\ origin\ *_fix_text
或
git rm "h origin "*_fix_text
答案 1 :(得分: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字符。我不确定它在其他操作系统上的其他浏览器上是如何显示的。)