git Git错误致命:无法统计'*':没有这样的文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14161297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:11:52  来源:igfitidea点击:

Git error fatal: unable to stat '*': No such file or directory

gitgithub

提问by coder

I ran into this error, and found very little documentation on how to fix it online. I got the error by trying to run the command git add ., and received this response:

我遇到了这个错误,并且发现关于如何在线修复它的文档很少。我通过尝试运行命令得到了错误git add .,并收到了这个响应:

fatal: unable to stat 'myPathToAFile': No such file or directory

致命:无法统计“myPathToAFile”:没有这样的文件或目录

回答by coder

To solve the problem, I removed the file from git, then re-added it by doing the following:

为了解决这个问题,我从 git 中删除了该文件,然后通过执行以下操作重新添加它:

git rm "myPathToAFile"

git rm "myPathToAFile"

git add .

git add .

git commit -am 'my commit'

git commit -am 'my commit'

Hope this helps someone else!

希望这对其他人有帮助!

回答by Babu James

回答by Peti

I had the same issue. I'm using Windows 7 and my problem was the "Maximum Path Length Limitation" (max 260 characters for the path) (see http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maxpathfor more details).

我遇到过同样的问题。我使用的是 Windows 7,我的问题是“最大路径长度限制”(路径最多 260 个字符)(请参阅http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29 .aspx#maxpath了解更多详情)。

My workaround was to shorten the classname a little bit.

我的解决方法是稍微缩短类名。

回答by Tejes

Another cause for this problem on Windows might be reserved file names. I bumped on them when I tried to clone the Linux Kernel repository out of curiosity on my Windows 10 machine, and Git could not create aux.c and aux.h files.

Windows 上出现此问题的另一个原因可能是保留文件名。当我出于好奇在我的 Windows 10 机器上尝试克隆 Linux 内核存储库时遇到了它们,并且 Git 无法创建 aux.c 和 aux.h 文件。

So you cannot create any file (with any extension) or folder named: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9, case insensitive.

所以你不能创建任何文件(带有任何扩展名)或文件夹命名为:CON、PRN、AUX、NUL、COM1、COM2、COM3、COM4、COM5、COM6、COM7、COM8、COM9、LPT1、LPT2、LPT3、LPT4、LPT5 、LPT6、LPT7、LPT8、LPT9,不区分大小写。

See: https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#naming-conventions

请参阅:https: //docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#naming-conventions

回答by J.Tribbiani

None of the above worked for me.

以上都不适合我。

Updating Git fixed the problem.

更新 Git 解决了这个问题。

回答by Obnebion

Similar to the comment by Tejes, I had this problem only with files called "aux.R", which I could not git pullonto a windows machine, while it works fine on my linux client.

与 Tejes 的评论类似,我只在名为“aux.R”的文件上遇到了这个问题,我无法git pull在 Windows 机器上使用它,而它在我的 linux 客户端上运行良好。

I fixed it by renaming it to "auxiliary.R", works now without any problem.

我通过将其重命名为“auxiliary.R”来修复它,现在可以正常工作了。