git 致命:无法读取当前工作目录:没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48293849/
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
fatal: Unable to read current working directory: No such file or directory
提问by Aerin
I'm a Windows 10 user, using gitbash as a command prompt.
我是 Windows 10 用户,使用 gitbash 作为命令提示符。
After I changed the branch to master
, suddenly I'm struck with this error message.
在我将分支更改为 之后master
,突然我被这个错误消息震惊了。
REDMOND+ahkim@ahkim-1211 MINGW64 /c/git/src/SI_leadscore/SalesIntelligence/LeadScore/Model (aerin/LeadOptimizerModel)
$ git checkout master
Switched to a new branch 'master'
Branch 'master' set up to track remote branch 'master' from 'origin'.
REDMOND+ahkim@ahkim-1211 MINGW64 /c/git/src/SI_leadscore/SalesIntelligence/LeadScore/Model
$ git checkout LeadOptimizerModel
fatal: Unable to read current working directory: No such file or directory
REDMOND+ahkim@ahkim-1211 MINGW64 /c/git/src/SI_leadscore/SalesIntelligence/LeadScore/Model
$ git branch
fatal: Unable to read current working directory: No such file or directory
REDMOND+ahkim@ahkim-1211 MINGW64 /c/git/src/SI_leadscore/SalesIntelligence/LeadScore/Model
$ git status
fatal: Unable to read current working directory: No such file or directory
git checkout, git branch, git status, etc. None of them works.
git checkout、git branch、git status 等。它们都不起作用。
回答by Neil Forrester
Your current directory doesn't exist on the master branch. It was deleted when you checked it out. cd ..
a few times until you find a directory that exists.
您的当前目录在 master 分支上不存在。当你检查它时它被删除了。cd ..
几次,直到找到存在的目录。
回答by Craig C.
I got this message when trying to execute git commands in crosh on a chromebook. The local files were on a removable drive (an SDXC card in this case). I fixed it by changing directory up and back into the repo's main directory:
我在 Chromebook 上尝试在 crosh 中执行 git 命令时收到此消息。本地文件位于可移动驱动器(在本例中为 SDXC 卡)上。我通过更改目录并返回到 repo 的主目录来修复它:
$ cd ..
$ cd ..
$ cd (my repo's directory)
$ cd(我的仓库目录)
And presto, git was working again. I've used this set up a lot, I have no idea what happened, other than maybe Chrome OS got confused and didn't know what was going on. But
而且很快,git 又开始工作了。我经常使用这个设置,我不知道发生了什么,除了 Chrome 操作系统可能感到困惑并且不知道发生了什么。但
$ pwd
$密码
worked fine before I fixed the issue, while the error was happening.
在我解决问题之前工作正常,而错误正在发生。