Ruby-on-rails 致命:不是 git 存储库(或任何父目录):每个 rails 命令上的 .git 但 git 命令工作正常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14199212/
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: Not a git repository (or any of the parent directories): .git on every rails command but git commands works fine
提问by coderuby
I've got a problem with git and my rails project.
我的 git 和我的 rails 项目有问题。
I have set up a github repository and successfully pushed four commits. Every git command i'm trying is working as expected (git status, git add, git commit, git pushetc.). But each time I try to execute a rails command (e.g. bundle show, bundle install, rails s, rails generate, rake testetc.) I get following message in my console:
我已经建立了一个 github 存储库并成功推送了四个提交。我正在尝试的每个 git 命令都按预期工作(git status, git add, git commit, git push等)。但是每次我尝试执行 rails 命令(例如bundle show, bundle install, rails s, rails generate, rake test等)时,我都会在控制台中收到以下消息:
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
Every time the message appears on three lines. Sometimes on six lines. The .gitfolder is in my project and I'm in the correct folder. all rails commands are working as expected. But this annoying message comes with each rails command. I cloned the repository into another folder and created another repository and pushed the code to that new repositiory. The error is in my new folder, too.
每次消息都出现在三行上。有时在六行。该.git文件夹在我的项目中,我在正确的文件夹中。所有 rails 命令都按预期工作。但是这个烦人的消息伴随着每个 rails 命令。我将存储库克隆到另一个文件夹并创建了另一个存储库并将代码推送到该新存储库。错误也在我的新文件夹中。
I reinitialized my existing Git repository with git initbut that changed nothing.
我重新初始化了我现有的 Git 存储库,git init但这没有任何改变。
When I set up a fresh rails project and push it into a new repository etc. there are no errors. What could be wrong with my project? Any idea, why this is happening and how to fix this?
当我设置一个新的 rails 项目并将其推送到新的存储库等时,没有错误。我的项目可能有什么问题?任何想法,为什么会发生这种情况以及如何解决这个问题?
I'm working with ruby 1.9.3, rails 3.2.1and git 1.7.9.
我正在使用ruby 1.9.3,rails 3.2.1和git 1.7.9。
thx to @manojlds I could isolate the problem a little bit more. It's the therubyracer gem. I don't know what exactly is the problem but because I'm on windows I use this special therubyracer gem: https://github.com/hiranpeiris/therubyracer_for_windows. So I will ask the developer of this special gem and will show him the bundler bug. Maybe he will know if it's a problem with his gem or with the bundler. The bundler has an updated pre release. But I can't install the prerelease on windows. So I have to wait and therefore I must live for now with this annoying messages. Or is there a way to disable these messages?
感谢@manojlds 我可以更多地隔离问题。这是 therubyracer 宝石。我不知道到底是什么问题,但因为我在 Windows 上,所以我使用这个特殊的 therubyracer gem:https: //github.com/hiranpeiris/therubyracer_for_windows。所以我会问这个特殊 gem 的开发者,并向他展示打包程序错误。也许他会知道这是他的宝石还是捆绑器的问题。捆绑器有一个更新的预发行版。但我无法在 Windows 上安装预发行版。所以我必须等待,因此我现在必须忍受这些烦人的消息。或者有没有办法禁用这些消息?
Here is my github issue: https://github.com/hiranpeiris/therubyracer_for_windows/issues/1
这是我的 github 问题:https: //github.com/hiranpeiris/therubyracer_for_windows/issues/1
采纳答案by manojlds
There is a bug for Bundler, which could be related: https://github.com/carlhuda/bundler/issues/2039
Bundler 有一个错误,可能与此相关:https: //github.com/carlhuda/bundler/issues/2039
Definitely not a problem with git or your git repo. Try updating bundler. ( not sure if the fix is in stable version yet )
绝对不是 git 或您的 git repo 的问题。尝试更新捆绑器。(不确定修复程序是否处于稳定版本)
回答by user2158765
Try running git initin
尝试运行git init在
RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0beta1-x86-mingw32.
RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0beta1-x86-mingw32.
It will initialize a new empty git repo there.
它将在那里初始化一个新的空 git repo。
回答by Fuzzy Analysis
Make sure you are in the right directory when you run that command:
运行该命令时,请确保您位于正确的目录中:
git tag
I had the same problem while installing node.js from git and found that I had to be in a subdirectory after downloading it for the tag versions to display.
我在从 git 安装 node.js 时遇到了同样的问题,发现下载后我必须在一个子目录中才能显示标签版本。
For example, I ran this command to get node.js:
例如,我运行这个命令来获取 node.js:
git clone https://github.com/joyent/node.git
... but then had to cd nodeto be in the node subdirectory before the git tagcommand worked.
...但 cd node必须在git tag命令工作之前位于节点子目录中。
回答by Michael Durrant
The rubytheracer gem has lots of issues.
rubytheracer gem 有很多问题。
Switch to node or execjs to avoid them.
切换到 node 或 execjs 以避免它们。

