gpt4 book ai didi

windows - 找不到要通过 git bash 删除的文件,但它显示在文件资源管理器中

转载 作者:可可西里 更新时间:2023-11-01 11:24:18 24 4
gpt4 key购买 nike

我昨天开始学习git,在创建ssh key 时出错,如第一张图所示。

create file img

我试过.bat删除方式和dos del命令,还是不能删除名为cd ..
的文件提示说找不到文件。文件大小属性为0字节。

file in explorer

如何删除这个文件?

最佳答案

我使用 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 ..走了

作为commented通过 eryksun ,

rm.exe isn't a Linux app. It uses msys-2.0.dll, which links with Windows API functions from kernel32.dll and native NT system calls from ntdll.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), and NtSetInformationFile (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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com