我昨天开始学习git,在创建ssh key 时出错,如第一张图所示。
我试过.bat
删除方式和dos del
命令,还是不能删除名为cd ..
的文件
提示说找不到文件
。文件大小属性为0字节。
如何删除这个文件?
最佳答案
我使用 cd ..
在 CMD Windows 中成功删除了“<path/to/git>\latest\usr\bin
”在 %PATH%
.这让我可以访问 rm.exe
.
vonc@VONCAVN7 C:\test
> where rm
D:\prgs\git\latest\usr\bin\rm.exe
我有:
vonc@VONCAVN7 C:\test
> dir /x
Volume in drive C is test
Directory of C:\test
08/08/2017 07:11 <DIR> .
08/08/2017 07:11 <DIR> ..
08/08/2017 07:11 0 cd ..
有了这个,我输入了:
vonc@VONCAVN7 C:\test
> rm cd*
和文件cd ..
走了
rm.exe
isn't a Linux app. It usesmsys-2.0.dll
, which links with Windows API functions fromkernel32.dll
and native NT system calls fromntdll.dll
.
In this case it's how it bypasses the Windows API to make direct system calls that solves the problem:NtOpenFile
(open the directory to list it and the "cd ..
" file to delete it),NtQueryDirectoryFile
(list the directory), andNtSetInformationFile
(set the file's delete disposition).
作为eryksun评论说,纯 Windows 语法(意思是,它不需要像 rm
这样的类似 Git Linux 的命令)也可以工作:
del "\\?\C:\test\cd .."
参见“What does \\?\
mean when prepended to a file path”。
这将禁用所有字符串解析并将其后的字符串直接发送到文件系统。
关于windows - 找不到要通过 git bash 删除的文件,但它显示在文件资源管理器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45558587/