fatal: Not a git repository (or any of the parent directories): .git on every rails command but git commands works fine

I’ve got a problem with git and my rails project.

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 push etc.). But each time I try to execute a rails command (e.g. bundle show, bundle install, rails s, rails generate, rake test etc.) I get following message in my console:

  • Let git bash launch at current repositories
  • How to right align something in Powershell prompt?
  • Git: move a branch to make it point to another
  • Preventing Git Remote branches from being deleted
  • Never-ending GIT story - what am I doing wrong here?
  • Cannot install git through homebrew on yosemite
  • 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 .git folder 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.

    I reinitialized my existing Git repository with git init but that changed nothing.

    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?

    I’m working with ruby 1.9.3, rails 3.2.1 and 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?

    Here is my github issue: https://github.com/hiranpeiris/therubyracer_for_windows/issues/1

  • Internal error while accessing GIT repository from RSA 9.1 using TFS plug-in
  • How can I rate limit git-svn?
  • Using git pull to track a remote branch without merging
  • How to operate a local branch in git
  • Warn when doing git commit -a if something is staged
  • What is a one-sentence explanation of how Accurev works?
  • 4 Solutions collect form web for “fatal: Not a git repository (or any of the parent directories): .git on every rails command but git commands works fine”

    There is a bug for Bundler, which could be related: 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 )

    Try running git init in

    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.

    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.

    For example, I ran this command to get node.js:

    git clone https://github.com/joyent/node.git
    

    … but then had to cd node to be in the node subdirectory before the git tag command worked.

    The rubytheracer gem has lots of issues.

    Switch to node or execjs to avoid them.

    More at: Rails – Could not find a JavaScript runtime?

    Git Baby is a git and github fan, let's start git clone.