Reputation: 35
I started to learn git yesterday, and I made a mistake when I created ssh key as the first image shows.
I tried .bat
delete way and dos del
command, still cannot delete file named cd ..
The prompt said cannot find file
. The attribute of file size is 0 byte.
How to delete this file?
Upvotes: 0
Views: 2114
Reputation: 1328712
I managed to delete "cd ..
" in a CMD Windows with <path/to/git>\latest\usr\bin
in %PATH%
. That gives me access to rm.exe
.
vonc@VONCAVN7 C:\test
> where rm
D:\prgs\git\latest\usr\bin\rm.exe
I had:
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 ..
With that, I typed:
vonc@VONCAVN7 C:\test
> rm cd*
And the file cd ..
was gone
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).
As eryksun commented, the pure Windows syntax (meaning, it does not need a Git Linux-like command like rm
) would have worked too:
del "\\?\C:\test\cd .."
See "What does \\?\
mean when prepended to a file path".
That will disable all string parsing and send the string that follows it straight to the file system.
Upvotes: 3
Reputation: 10447
Look into the properties of the file. There you may find file location. Go to that location and delete from there.
And see which type of file is it. I mean, it may be a system file, and if it is, system will not allow you to delete it. Open explorer as administrator and then try deleting it.
Upvotes: 0